| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Termination queue(s) |
PC> My app starts up to 3 other apps using DosStartSession().
PC> Should I use a different termination queue for each or one queue
PC> for all spawned apps?
PC> I guess if I used only one queue, then I'd need a thread dedicated to
PC> reading the queue.
I've never done it, but I think you only need one queue.
Actually, I'm 99% sure -- I have an app that only starts one program
directly, but the many children that that program starts all end up
sending start/end messages to my term queue. My program is a debuggger;I
don't think normal apps get a "start message" on their
termination queue.
You only need a separate thread if your app has to go on and do other stuff
(which is probable).
For what's it worth, here's my code:
typedef struct _qstart {
USHORT pidSession;
USHORT pidProcess;
USHORT pidParentSession;
USHORT pidParentProcess;
}QSTART;
typedef struct _qdie {
USHORT pidSession;
USHORT retcode;
}QDIE;
REQUESTDATA qr;
QDIE *qd;
QSTART *pv = NULL;
...
i = 0;
do{
sprintf(qname, "/queues/termq%d", i++);
rc = DosCreateQueue(&hq, QUE_FIFO, qname);
}while(rc == ERROR_QUE_DUPLICATE);
if(rc){
printf("Could not create queue(%s)\n", qname);
crc(rc);
exit(3);
}
memset(&StartData, 0, sizeof(STARTDATA));
StartData.Length = 50; //sizeof(STARTDATA);
StartData.Related = SSF_RELATED_CHILD;
StartData.FgBg = SSF_FGBG_BACK;
StartData.TraceOpt = SSF_TRACEOPT_TRACEALL;
StartData.PgmTitle = 0;//"Bug-A-Boo!";
StartData.PgmName = pgm;
StartData.PgmInputs = parms;
StartData.TermQ = qname;
StartData.Environment = 0;
StartData.InheritOpt = SSF_INHERTOPT_PARENT;
StartData.SessionType = SSF_TYPE_DEFAULT;
StartData.IconFile = 0;
StartData.PgmHandle = 0;
StartData.PgmControl = 0;
StartData.Reserved = 0;
StartData.ObjectBuffer = ObjBuf;
StartData.ObjectBuffLen = sizeof(ObjBuf);
rc = DosStartSession(&StartData, &SessID, &pid);
if (rc != 0 && rc != ERROR_SMG_START_IN_BACKGROUND){
//logf(NULL, "DosStartSession error: return code =
%ld\n%s\n", rc, ObjBuf);
logf(NULL, "Could not start '%s'\n", pgm);
crc(rc);
exit(1);
}
DosSetPriority(PRTYS_PROCESS, PRTYC_FOREGROUNDSERVER, 1, 0);
_beginthread(TraceProc, (PVOID)NULL, 0x4000, (PVOID)(ULONG)pid);
do{
rc = DosReadQueue(hq, &qr, &len, (PPVOID)&pv, 0,
DCWW_WAIT, &prty, 0L);
if(rc){
crc(rc);
exit(3);
}
if(qr.ulData == 0){
qd = (QDIE *)pv;
logf(NULL, "Session %04x has closed, resultcode =
%d\n", qd->pidSession, qd->retcode);
sessions--;
}
else if(qr.ulData == 1){
logf(NULL, "NEW SESSION: %04x\n", pv->pidSession );
mesg(NULL, "pidProcess; %x\n", pv->pidProcess );
mesg(NULL, "pidParentSession %x\n", pv->pidParentSession);
mesg(NULL, "pidParentProcess %x\n", pv->pidParentProcess);
sessions++;
}
else{
mesg(NULL, "\a\nREADQ: pid = %lu, code = %lu\n\a",
qr.pid, qr.ulData);
}
DosFreeMem(pv);
}while(sessions>0);
logf(NULL, "Done.\n");
--- Maximus/2 3.00
* Origin: Sol 3 * Toronto * V.32 * (905)858-8488 (1:259/414)SEEN-BY: 50/99 270/101 620/243 625/160 711/401 409 410 413 430 808 809 934 SEEN-BY: 711/955 712/407 515 624 628 713/317 800/1 @PATH: 259/414 400 99 250/99 3615/50 396/1 270/101 712/515 711/808 934 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.