SIGCHLD signal handler in qnx4.25

Hi there

Is SIGCHLD signal handler to be armed after the signal is delevered to the
application?
Is it possible that the system area that is used by signal call is over
written by user code?

Here is a brief description of the code:
a) Signal Handler
Signal handler is associated with SIGCHLD signal using a signal system
call.
The event that trigers the signal is the death of child processes that
were
previously launched using qnx_spawn system call.

SigChildHandler()
{
gSigFlg = 1;
}

b) Uniqe Read function
Read(…)
{
if (gSigFlg)
processCleanup()
while ((pid= receive(0…))==-1)
{
processCleanup()
if (gSigFlg)
processCleanup()
}

}
processCleanup()
{
while ((pid = waitpid(0,NULL,WNOHANG) == -1)
put a application’s process termination in the application’s
msgque.
gSigFlg = 0
}

This code is organized in a library which is linked to application.
In a thin application this works fine.
In a heavy application the s flag in the qnx process control word is
cleared
after the second child death - on returning from the signal handler.
I watch this flag using sin -P appname flags .

Thanks
Rami

“Rami Raviv” <raviv_r@netvision.net.il> wrote in message
news:9pt4i6$fp5$1@inn.qnx.com

Hi there

Is SIGCHLD signal handler to be armed after the signal is delevered to
the
application?
Is it possible that the system area that is used by signal call is over
written by user code?

Here is a brief description of the code:
a) Signal Handler
Signal handler is associated with SIGCHLD signal using a signal system
call.
The event that trigers the signal is the death of child processes that
were
previously launched using qnx_spawn system call.

SigChildHandler()
{
gSigFlg = 1;
}

b) Uniqe Read function
Read(…)
{
if (gSigFlg)
processCleanup()
while ((pid= receive(0…))==-1)
{
processCleanup()
if (gSigFlg)
processCleanup()
}

}
processCleanup()
{
while ((pid = waitpid(0,NULL,WNOHANG) == -1)
put a application’s process termination in the application’s
msgque.
gSigFlg = 0
}

In the clean up process it’s possible that the signal handler function

is called between the while and the gSigFlag = 0; Hence you would
end up with sSigFlag being set to 0 without a call to processCleanup().

To go around this potentiel problem you could instead increment gSigFlg
in the handler and decrement it in the process cleanup function.

This code is organized in a library which is linked to application.
In a thin application this works fine.
In a heavy application the s flag in the qnx process control word is
cleared
after the second child death - on returning from the signal handler.
I watch this flag using sin -P appname flags .

Thanks
Rami
\

Rami Raviv <raviv_r@netvision.net.il> wrote:

Hi there

Responded in detail in the QNX4 conference.

-David

QNX Training Services
dagibbs@qnx.com