ClosestStorm / v8cgi

Automatically exported from code.google.com/p/v8cgi
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

The exit code is not properly set when an error is thrown or exit(1) is used #109

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
  Run the attached two files (single line code in each) with v8cgi. Check the status code returned by "echo $?". It is set to 0, whereas this is abnormal termination in case of "throw", and explicitly returned exit(1) in second case.

I am using the latest checkout of v8cgi (r1003) on an Ubuntu 11.10 (64-bit) 
machine.

The tagged 0.9.2 version 
(http://code.google.com/p/v8cgi/downloads/detail?name=v8cgi-0.9.2-src.tar.gz) 
returns correct status code (1 in both case). So some changes from 0.9.2 to 
r1003 breaks this.

Original issue reported on code.google.com by anuragbi...@gmail.com on 11 Feb 2012 at 1:23

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by ondrej.zara on 11 Feb 2012 at 1:05

GoogleCodeExporter commented 9 years ago
Philosophical question: the exit() function accepts no arguments; what status 
code should be returned if exit() accepted a code and was called as "exit(0)"? 

Exiting the code flow via the means of JS exit() function seems like a 
non-standard way of terminating the execution; should v8cgi itself return 0 or 
a non-zero code?

Original comment by ondrej.zara on 11 Feb 2012 at 1:18

GoogleCodeExporter commented 9 years ago
IMHO, exit() *should* accept an argument (exitCode - an integer value), and if 
provided that exit code should be returned by v8cgi. If the input argument is 
omitted (e.g., already existing v8cgi code), then a non-zero could should be 
returned (for backward compatibility, since v8cgi 0.9.2 does that.) Though in 
general it seems 0 is default value used by most languages (e.g. - Python: 
http://docs.python.org/library/sys.html#sys.exit)

It's seems plausible that a programmer will most likely use exit() for abnormal 
termination, but it is also likely that exit() is used for successful 
termination (e.g., exiting successfully from some deeply nested loop in a 
deeply nested function call).

Original comment by anuragbi...@gmail.com on 11 Feb 2012 at 11:01

GoogleCodeExporter commented 9 years ago
Okay; exit will accept an argument, its default value will be 1.

Original comment by ondrej.zara on 12 Feb 2012 at 8:30

GoogleCodeExporter commented 9 years ago
Fixed in revision 1004.

Original comment by ondrej.zara on 12 Feb 2012 at 1:23