0

I have a PHP CLI script ( http://codepad.org/w6iyLLdv ) which stubbornly returns exit code 11, despite the exit(0) and the lack of any apparent problem.

Advanced Bash-Scripting Guide: Appendix E. Exit Codes With Special Meanings lists nothing special about 11, and Google finds nothing about it in general nor specifically related to PHP - except possibly Are there any standard exit status codes in Linux?.

Of course I can check for an exit status of 0 or 11 in my calling code, but that's dirty.

Community
  • 1
  • 1
Grault
  • 974
  • 12
  • 31
  • http://stackoverflow.com/questions/5255218/why-is-it-returning-exit-status-11 – Mikhail Mar 10 '11 at 03:53
  • 2
    Duplicate of http://stackoverflow.com/questions/5255218/why-is-it-returning-exit-status-11 - sorry, poor communication! (Mikhail beat me to it.) – Grault Mar 10 '11 at 03:55

2 Answers2

1

I finally thought to check Apache's error.log, and the 11 status was accompanied by this: PHP Warning: Module 'imagick' already loaded in Unknown on line 0

I found the solution here: http://www.somacon.com/p520.php Apparently I accidentally put an extra << extension="imagick.so" >> line in php.ini. Removing it allowed the CLI script to return status 0.

Note: After I posted this, I started getting a PHP-Warning from imagick about no permissions to create the ~/.gnome2 directory, and the 11 status. So seeing the 0 status after applying this fix may have been a fluke.

Grault
  • 974
  • 12
  • 31
0

Is it exiting with exit code 11, or signal 11? If it's the latter, it's crashing with a SIGSEGV.

Otherwise, see if you can figure out which line it is exiting on. For example, insert exit(0); after the 10th line, and if it exits with 0 instead of 11 move the exit(0) down a bit. That will at least give us something more to work with.

Anomie
  • 92,546
  • 13
  • 126
  • 145
  • It is simply the number placed in the third argument to `exec'; my understanding was that that's the exit status. By using your advice I was able to confirm that it doesn't exit until that exit(0) in the code. Placing an exit before that if-block prevented the 11 status. – Grault Mar 10 '11 at 06:08
  • Correction: Aapparently I made a mistake in my debugging; the call to flattenImages is the first thing which, if exit(0) comes before it, the 11 status is prevented... So it's an Image Magick issue. – Grault Mar 11 '11 at 21:25