Does exit code status with zero value always mean successfully run in Perl?

quinekxi picture quinekxi · Mar 23, 2012 · Viewed 7.3k times · Source

I have a Perl script that will execute three applications. All of it have different exit code status.

First application exit code status is 1. The application exited normally without any problem. (Successful)

Second application exit code status is 99. Still, the application exited normally without any problem. (Successful)

Lastly, the third application exit code status is 0. The same with the first and second, the application exited normally without any problem. (Successful)

Note: Already shift the exit code status 8 bits to right.

Question is, does the exit code status always return to 0 if successfully run?

Please no harsh comment, I just confused. Please advice.

Answer

Borodin picture Borodin · Mar 23, 2012

The return status is chosen by the child process. It is conventionally zero for successful operation but there is nothing to enforce that convention.

It is also possible for processes to return informational return statuses which indicate different forms of success. For instance, a program that modified all files in a directory may return a non-zero value to say that there were no files to modify.

You should check the documentation of the applications to see if anything is mentioned about what values may be returned. If you can find nothing then you should decide empirically what values indicate success.