I am running mongoose 3.7 server on my qnx system.
I receive http request to upgrade the firmware. On the request, I use, system()
call in the request handler to upgrade the firmware.
But, strangely, system()
returns 255. The same call was working before with mongoose 2.0.
Even more strange, the command which I issued through the system()
call works after it returned 255.
I am using WEXITSTATUS
to know the error which system()
returns
Any idea why this is happening?
I found the issue..
The issue was that the mongoose call back thread which issues the system() command will not wait for the return status becuase of this line:
On the mg_start() function, which starts the server thread, they have included this line:
mg_start()
line no 5159:They have done this inorder to not create a zombie process.
Ref: http://www.win.tue.nl/~aeb/linux/lk/lk-5.html
But, According to QNX documentation,
calling
SIG_IGN
onSIGCHLD
causes the parent process to ignore the status signal from the child.When we make a
system()
call, it blocks the SIGCHLD signal from the shell that is being launched. According to UNIX documentation:But, since mongoose discards the signal, it does not wait for the signal from
system()
at all.It simply continues to serve the response without a valid return status from
system()
.I just commented out this line for the time being. And it’s working.