When I call system(0) it returns 0, which means shell is not available.
When a command using system (calls gcc to compile a hello world program), it works just fine but returns -1 (I assume it's the same cause as for system(0) returning 0). What causes it to be "not available" and why does it work anyway?
Compiler: gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
OS: Ubuntu 11.10
EDIT
Errno says No Child Processes.
I have also compiled another test program that does not do anything but calls system(0) and it returns nonzero value. Can it be affected by Code::Blocks?
EDIT
So far I have figured out that system(0) only fails after I start my first pthread.
SOLVED
I used fork in my early implementation of one of this piece of code:
signal(SIGCHLD,SIG_IGN);
I used it to "handle" zombies. I just found out that this caused the error.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…