Workbench library issue

This forum is for general developer support questions.
Post Reply
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Workbench library issue

Post by OldFart »

Hi,

I encounter some strange behaviour when running this piece of code:

Code: Select all

/*
 * Project.c
 *************/

#include <stdio.h>
#include <string.h>

#include <exec/nodes.h>
#include <exec/lists.h>
#include <exec/types.h>
#include <exec/tasks.h>
#include <proto/exec.h>

#include <proto/wb.h>
#include <workbench/workbench.h>

#include <proto/dos.h>

#define ELSE_ERROR(Err) else IDOS->Printf("ERROR: Failed to %s\n", Err)
#define INFO(info) IDOS->Printf("INFO : %s\n", info)

int main(int argc, char *argv[])
{
// INFO("=== Start of Program  ===");

 struct Library *WorkbenchBase = IExec->OpenLibrary("workbench.library", 50L);

 if (WorkbenchBase)
  {
   struct WorkbenchIFace *IWorkbench = (struct WorkbenchIFace *)IExec->GetInterface(WorkbenchBase, "main", 1L, TAG_DONE); 

   if (IWorkbench != NULL)
    {
     struct List *list = NULL;

     if ((IWorkbench->WorkbenchControl(NULL, WBCTRLA_GetProgramList, &list, TAG_DONE)) == TRUE)
      {
       STRPTR ProgName;
       struct Task *Task;
       struct Node * node = IExec->GetHead(list);
       INFO("=== Start of List    ===");

       while (node != NULL)
        {
         ProgName = (STRPTR)IDOS->FilePart(node->ln_Name);
         IDOS->Printf("INFO : [ %08lx ]", node);

         if ((Task = IExec->FindTask(ProgName)) != NULL)
          {
           IDOS->Printf(" -- [ %08lx ] | [ %3ld ]", Task, Task->tc_Node.ln_Pri);
          }
         else
          {
           IDOS->Printf("                          ");
          }

         IDOS->Printf(" -- %s\n", ProgName);
         
         node = IExec->GetSucc(node);
        }

       INFO("==== End of List    ====");

       if ((IWorkbench->WorkbenchControl(NULL, WBCTRLA_FreeProgramList, list, TAG_DONE)) == FALSE)
        {
         INFO("Free Programlist failed");
         IDOS->Printf("Failer due to [ %ld ]\n", IDOS->IoErr());
        }
      }
     ELSE_ERROR("Get ProgramList");

     IExec->DropInterface((struct Interface *)IWorkbench);
    }
   ELSE_ERROR("Get Interface");

   IExec->CloseLibrary(WorkbenchBase);
  }
 ELSE_ERROR("Open Library");

 INFO("==== End of Program ====");
	 
 return 0;
}
It compiles nicely with:

Code: Select all

SWITCHES  = -W                     \
            -Werror                \
            -Wmissing-prototypes   \
            -Wsign-compare         \
            -Wundef                \
            -Wwrite-strings

DEBUG     = 

FILES     =  main.c

ProjecT.DEBUG : $(FILES)
	gcc main.c -o ProjecT.DEBUG $(SWITCHES) $(DEBUG)
	@echo "=== Done making DEBUG ================="
It even RUNS properly, providing the info asked for so what is the problem?

Well, the problem is that when even a small and minor change, like uncommenting the first line in main(), is applied to the source and compiled again, I get this compilation message:

Code: Select all

gcc main.c -o ProjecT.DEBUG -W -Werror -Wmissing-prototypes -Wsign-compare -Wundef -Wwrite-strings  
ld: cannot open output file ProjecT.DEBUG: Text file busy
make: *** [ProjecT.DEBUG] Error 1
Other tags like WBCTRLA_GetOpenDrawerList & WBCTRLA_FreeOpenDrawerList, WBCTRLA_GetSelectedIconList & WBCTRLA_FreeSelectedIconList and others do NOT show this behaviour.

Could anyone please comment?

OldFart
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
User avatar
colinw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 207
Joined: Mon Aug 15, 2011 9:20 am
Location: Brisbane, QLD. Australia.

Re: Workbench library issue

Post by colinw »

Works for me. !!
What editor are you using ?
because it sounds like it may have a filehandle left open somehow.

Run the "filehandlescan" program, (in SDK:c) passing it the volume name of the
partition where you are compiling to, see if anything is left open.

All I did here was copy your code and add the following to the top of the file
called main.c then just execute it as a script file.

;/* to compile; execute main.c
;-------------------------------------
set bname WBListTest
gcc main.c -o $bname -W -Werror -Wmissing-prototypes -Wsign-compare -Wundef -Wwrite-strings
strip -g --strip-unneeded $bname -o $bname
quit
*/
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Re: Workbench library issue

Post by OldFart »

Hi Colin,

Thanks for looking into it.

The editor I use is NotePad, but it eludes me why a filehandle would be left open about an executable by a mere plaintexteditor.

My workbench.library has version 53.53



OldFart
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
User avatar
nbache
Beta Tester
Beta Tester
Posts: 1714
Joined: Mon Dec 20, 2010 7:25 pm
Location: Copenhagen, Denmark
Contact:

Re: Workbench library issue

Post by nbache »

OldFart wrote: Sun Mar 28, 2021 12:24 pmMy workbench.library has version 53.53
Then you have not installed Update 2.

That's the version from AmigaOS 4.1 FE Update 1.

Best regards,

Niels
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Re: Workbench library issue

Post by OldFart »

@niels

That's the OS-version I have installed. Unresolved issues with (obtaining) the updates from december 2020.

Regards
Tjitte
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Re: Workbench library issue

Post by OldFart »

@Colin

I've been looking into it myself again and took the following steps:

I copied a full project over, which did not show the above mentioned behaviour. This one use the tags about OpenDrawers (for short).
Without copying anything over from the existing example that used the tags about the Programs, I rebuilt the source, compiled it and ran it. Again this all went ok and according to plan.

But then I made a minor change to the source and (tried to) compile it. And again I was greeted with a message that the executable could not be rewritten as it was 'busy'.
My stance remains that something is hogging the executable even after it finishing execution. And it has something to do with the tags.

What is de exact name of that command in SDK:C? About locks?

OldFart
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
blmara
Posts: 76
Joined: Thu Jun 23, 2011 9:03 am
Location: Vantaa, Finland

Re: Workbench library issue

Post by blmara »

@OldFart

About the SDK:C question: it was FileHandleScan

For some reason, in my SDK installation that file had it's executable flag not set. I set it with

protect sdk:c/filehandlescan +e

After that the program executed nicely.

Marko
Marko
User avatar
OldFart
Posts: 100
Joined: Tue Jul 12, 2011 2:56 pm
Location: Groningen, Netherlands

Re: Workbench library issue

Post by OldFart »

@blamara

Searched the full SDK for a file called 'FileHandleScan' and guess what? Nothing was found...

Thanks anyway.

OldFart
X5000, appears to be sick. Dismantled jan 1, 2024.
Dead MicroA1
A1200 in ElBox, c/w Blizzard '040 @ 50MHz + SCSI module, ZIV-board c/w (o.a.) cv64/3d + flickerdoubler + FastATA-ZIV + Lots of SCSI gear, sitting idle.
RaspBerry Pi 2B, 3B, 4B/4Gb, 4B/8Gb
OrangePi 5+ 8Gb
ACER Windows 10
User avatar
colinw
AmigaOS Core Developer
AmigaOS Core Developer
Posts: 207
Joined: Mon Aug 15, 2011 9:20 am
Location: Brisbane, QLD. Australia.

Re: Workbench library issue

Post by colinw »

You need to go to the Hyperion website; https://www.hyperion-entertainment.com/
log in with your account credentials, click on "Downloads" and go into the
"AmigaOS 4.1 Final Edition" directory and get Update 2.

All your problems will likely go away, and you will get the DOS SDK update installed
from inside that archive too. It also has the tools you are missing in SDK:c
Post Reply