Page 1 of 1

Workbench library issue

Posted: Fri Mar 26, 2021 8:49 pm
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

Re: Workbench library issue

Posted: Sat Mar 27, 2021 11:29 pm
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
*/

Re: Workbench library issue

Posted: Sun Mar 28, 2021 1:24 pm
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

Re: Workbench library issue

Posted: Sun Mar 28, 2021 2:42 pm
by nbache
OldFart wrote: Sun Mar 28, 2021 1: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

Re: Workbench library issue

Posted: Mon Mar 29, 2021 12:17 pm
by OldFart
@niels

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

Regards
Tjitte

Re: Workbench library issue

Posted: Mon Mar 29, 2021 7:58 pm
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

Re: Workbench library issue

Posted: Fri Apr 02, 2021 10:33 am
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

Re: Workbench library issue

Posted: Sat Apr 03, 2021 1:40 pm
by OldFart
@blamara

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

Thanks anyway.

OldFart

Re: Workbench library issue

Posted: Mon Apr 05, 2021 12:38 am
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