The source below is compiled with
gcc guis:Dev/Gui4Cli_Dev/G4C_18/piper.c -gstabs -lauto -N -o g18:piper
and gives no errors or warnings.
The debug print statements observed are indicated with "seen"
int main(void) { LONG ProgRET=20, c ;///d BOOL rxmsgreplied=0; ///, wnmsgreplied, flag=0; char *buff=NULL;/// *gcdata=NULL; int stop=0; ///, comret, INTUIisopen=0; struct RexxMsg *rxmsg = NULL; struct g4cmsg *gcmess= NULL; struct Remember *rkey=NULL; struct LaunchMessage *lmess; ///used also with xPIPE handling char *pt; ///*gp=NULL, *pt; ///struct GCmain *gd=NULL; strcpy (myportname, "Gui4Cli"); // * name of default port * / RexxSysBase = OpenLibrary ("rexxsyslib.library",45); //changed if (RexxSysBase) IRexxSys = (APTR)GetInterface(RexxSysBase, "main", 1L, NULL); //changed else PutStr("no RexxSysBase"); // not seen if (!(gd = (struct GCmain *)AllocRemember (&rkey, sizeof(struct GCmain), MEMF_CLEAR))) /// IIntuition-> { PutStr("no GCmain obtained\n"); //not seen goto endprog; } initgd (); // ------------------------ get main buffers ----------------------- if (!(getbuffers(gd->buffsize, 0))) { PutStr("no buff obtained\n"); /// IDOS-> //not seen goto endprog; } buff = gd->membuff[0]; // *------------------- Get default console ---------------------* / // *------------------------- PASS to other Gui4Cli if running -----------* / // *---------------------- Open Message ports ----------------------* / // *------------------------ Open other libs etc.. -----------------------* / if ( ! IntuitionBase || !UtilityBase ) goto endprog; if ( ! IIntuition || !IUtility ) goto endprog; if ( ! DOSBase ) goto endprog; if ( ! IDOS ) goto endprog; if ( ! RexxSysBase ) goto endprog; if ( ! IRexxSys ) goto endprog; Dp(PutStr("Main 7\n")); //seen Dp(Printf ("Findport %s \n", myportname)); /// Findport Gui4Cli seen Forbid (); //IExec-> taskscheduler if (FindPort(myportname)==NULL) { Dp(Printf ("Findport %s \n", myportname)); /// Findport Gui4Cli Seen myrxport=AllocSysObjectTags(ASOT_PORT, ASOPORT_Name, myportname, TAG_END); /// IExec-> } Permit(); /// IExec-> if (!myrxport) { Printf ("%s could not create myPorts\n", myportname); /// SEEN ??? ProgRET = 20; goto endprog; }
I don't understand what could go wrong with the AllocSysObject here (copied from a source where it works oK.
What other tests could i add before these last lines ??
Is it possible that you have run out of signals?
The default for AllocSysObject(ASOT_PORT...) is to allocate a signal. If this allocation fails, I would expect the AllocSysObject() to fail as well.
Just one suggestion, but that would explain why the same code worked elsewhere but not here.
Good Luck!
LyleHaze
LyleHaze
I'm not sure the AllocSysObject Call can work inside a pair of Forbid()/Permit() calls?
Rather than putting the whole AllocSysObjectTags() call within Forbid()/Permit() you might want to do it like this:
As mentioned one reason the port allocation might fail is that all your task's user signals are already allocated (there are 16 of them). To check for this you might want to add a debug statement like this before the AllocSysObjectTags() call:
@salass00
I started adding your printf statement
Is this correct or faulty ?
Anyway i found out that completing the initgd() function a bit more (adding the last line -presnt in the original
seemed to solve the problem
I now get
The source changed with the improved intigd() and the additioanl debug Printf suggested
allready detects the presence of an axisting Gui4Cli port and exits upon its detection
giving the intended error message
Thanks to all for help
So the problem is solved now?
If all user signals were allocated the value of tc_SigAlloc would have been 0xFFFFFFFF. The low 16 bits are signals reserved for system use so they will always be allocated.
Also don't call Printf() or other dos.library/file I/O functions while in Forbid() as they will Wait() causing the forbid state to be broken.
@salass00
Yes, but it is not the last problem i have with this source.
thanks for suggestions