Process module: exit code reporting is broken
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Zorba |
New
|
Medium
|
Cezar Andrei |
Bug Description
On Windows, the returned <exit-code> will always be 0. (The variable exit_code in process.cpp is never changed in the #ifdef WIN32 section.)
On Linux, <exit-code> seems to vary from distribution to distribution. On Ubuntu, it currently behaves "Correctly", in that a process which dies on a signal will return an exit code of 128 + signal number. However, on Fedora, a process that dies on a signal returns an exit code of 0. This seems to be because Ubuntu and Fedora differ in the meaning of the WEXITSTATUS() macro. As documented, this macro should only be used when WIFEXITED() reports that the child exited normally. On Fedora, this apparently is taken literally, and WEXITSTATUS() does not function at all (returning 0) if the child did not exit normally. On Ubuntu, WEXITSTATUS() does what you'd kind of want it to do, which is why the current process module code works there (the process module never checks WEXITSTATUS() and always returns whatever WEXITSTATUS() reports).
All of this behaviour is also undocumented in the process module: the module itself simply says that the <exit-code> element "returns the exit code of the child process". This needs documenting much more clearly in the case of a child that crashes, and there needs to be some cross-platform way of reporting crashes usefully.
Related branches
- Paul J. Lucas: Approve
- Chris Hillery: Approve
- Sorin Marian Nasoi: Approve
-
Diff: 126 lines (+44/-32)2 files modifiedsrc/com/zorba-xquery/www/modules/process.xq (+8/-0)
src/com/zorba-xquery/www/modules/process.xq.src/process.cpp (+36/-32)