spawn strange behaviour

Hello,

qnx_spanwn_options |= _SPAWN_NOZOMBIE;
spawnl (P_WAIT, …

When i do that, the spawnl never returns and my process is blocked. I think
this is because _SPAWN_NOZOMBIE is not compatible with P_WAIT in spawn
function.
I know that the _SPAWN_NOZOMBIE is useless since i wait for the end of the
spawned process (P_WAIT). But if i set this flag for other reasons in
another part of my code, i must reset it before spawning another process
(with P_WAIT).
I’ve spend 2 hours to correct this bug.

This is undocumented.

Is this a kernel bug or just an undocumented thing ??
I’m Waiting for your comments.

Thanks.

Sebastien Cantos <scantos@technodiva.com> wrote:

qnx_spanwn_options |= _SPAWN_NOZOMBIE;
spawnl (P_WAIT, …

When i do that, the spawnl never returns and my process is blocked. I think
this is because _SPAWN_NOZOMBIE is not compatible with P_WAIT in spawn
function.
I know that the _SPAWN_NOZOMBIE is useless since i wait for the end of the
spawned process (P_WAIT). But if i set this flag for other reasons in
another part of my code, i must reset it before spawning another process
(with P_WAIT).

Sure. If you set a flag in a global variable, it stays set until you
unset it. That’s how global variables normally behave in C. Why do you
find it surprising?..

I’ve spend 2 hours to correct this bug.

Well, the bug was in your code. One part of your code sets the flag and
never unsets it, and another part assumes that the flag is unset.

flame
This is undocumented.
/flame

What is undocumented? The fact that spawnl() does not modify
qnx_spawn_options? Do our docs suggest that it does?..

Is this a kernel bug or just an undocumented thing ??

I don’t think it’s either…

I’m Waiting for your comments.

Sebastien Cantos <scantos@technodiva.com> wrote:

Hello,

qnx_spanwn_options |= _SPAWN_NOZOMBIE;
spawnl (P_WAIT, …

When i do that, the spawnl never returns and my process is blocked. I think
this is because _SPAWN_NOZOMBIE is not compatible with P_WAIT in spawn
function.
I know that the _SPAWN_NOZOMBIE is useless since i wait for the end of the
spawned process (P_WAIT). But if i set this flag for other reasons in
another part of my code, i must reset it before spawning another process
(with P_WAIT).
I’ve spend 2 hours to correct this bug.
flame
This is undocumented.

Hm…
from _qnx_spawn_options:

This global structure sets the default values to be passed to
qnx_spawn() when any of the spawn…() and exec…() functions
are called.

From qnx_spawn():

_SPAWN_NOZOMBIE
When the new process terminates it won’t become a zombie waiting
for its parent to do a wait on its death. The parent (you) won’t
see the process die, and a SIGCHLD won’t be set.

So, you then called spawnl(P_WAIT). That says load the program and
wait for it to die – but you’d specifically set a flag that said to
the OS “don’t tell me about the death of any children”.

I guess the _qnx_spawn_options page could have a “warning playing
with under-the-covers with globally exported structures might cause
unexpected side-effects”.

Is this a kernel bug or just an undocumented thing ??
I’m Waiting for your comments.

It is definitely not a kernel bug. In fact, it isn’t even particularly
undocumented.

-David

QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.

Hm…
from _qnx_spawn_options:

This global structure sets the default values to be passed to
qnx_spawn() when any of the spawn…() and exec…() functions
are called.

From qnx_spawn():

_SPAWN_NOZOMBIE
When the new process terminates it won’t become a zombie waiting
for its parent to do a wait on its death. The parent (you) won’t
see the process die, and a SIGCHLD won’t be set.

So, you then called spawnl(P_WAIT). That says load the program and
wait for it to die – but you’d specifically set a flag that said to
the OS “don’t tell me about the death of any children”.

I guess the _qnx_spawn_options page could have a “warning playing
with under-the-covers with globally exported structures might cause
unexpected side-effects”.

Is this a kernel bug or just an undocumented thing ??
I’m Waiting for your comments.

It is definitely not a kernel bug. In fact, it isn’t even particularly
undocumented.

I think there should be a warning in the spawn* function help page
saying that if we use P_WAIT, the _SPAWN_NOZOMBIE should not be set in the
qnx_spawn_option, OR another solution would be that the kernel not use
_SPAWN_NOZOMBIE even if it set when P_WAIT is used OR spawn* function should
return an error.
But that’s no problem i know it now and i won’t do the same error twice.
Just hope that other developers won’t face the same problem.

Thanks for all.