{C++ etc.}

Latest Posts
 
Home | C++ Posts | Linux Posts | Programming Posts | Issue Tracking Posts

Monday, April 20, 2009

posix_spawnp Failure with WEXITSTATUS 127

One problem with posix_spawnp is that if it fails after successfully spawning a new process, the exit status of the spawned process is always 127. This gives us no clue what so ever as to what caused the problem.
I came across this a few days ago and struggled with it for a while before re-writing the code using "fork()" and "execvpe" to achieve the same effect. The "exec" calls also failed but they gave a proper error value (via errno) from which the cause of the error could be found (perror(errno)).
In my case, errno was 14 and the error message said "Bad address" which turned out to be caused by an invalid argument list passed to execvpe. I wasn't terminating the argument list with NULL set as the last element.
Having a better error reporting system in posix_spawnp would have saved me alot of trouble

No comments: