Last Comment Bug 718786 - JavaScript shell exits with a zero status when program is terminated
: JavaScript shell exits with a zero status when program is terminated
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: JavaScript Engine (show other bugs)
: unspecified
: All All
: -- normal (vote)
: mozilla12
Assigned To: general
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-01-17 12:31 PST by Jim Blandy :jimb
Modified: 2012-01-29 11:08 PST (History)
3 users (show)
jimb: in‑testsuite+
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
Make the shell exit with EXITCODE_RUNTIME_ERROR when code is terminated. (4.68 KB, patch)
2012-01-25 18:34 PST, Jim Blandy :jimb
jorendorff: review+
Details | Diff | Splinter Review

Description Jim Blandy :jimb 2012-01-17 12:31:17 PST
If the JavaScript shell runs a file (via -f) whose code terminates (that is, execution returns an error, but no exception is set), the shell exits with a zero status. It should only exit with a zero status when all files specified by -f and scripts given using -e complete successfully.

For example:

$ cat foo.js
terminate();
$ cat bar.js
print("Hi, from bar!");
$ js -f foo.js; echo $?
0
$ js -f bar.js; echo $?
Hi, from bar!
0
$ js -f foo.js -f bar.js; echo $?
Hi, from bar!
0
$ 

(Here, 'terminate' is the function defined by the patch in bug 717417.)
Comment 1 Jim Blandy :jimb 2012-01-25 18:34:54 PST
Created attachment 591676 [details] [diff] [review]
Make the shell exit with EXITCODE_RUNTIME_ERROR when code is terminated.

In js/src/jit-test/jit_test.py, add an 'exitstatus' jit-test cookie
attribute (and rename test.error to test.expect_error). Mark tests that
terminate with their expected termination code.

Clean up TMFLAGS comments.
Comment 2 Jason Orendorff [:jorendorff] 2012-01-25 18:48:50 PST
Comment on attachment 591676 [details] [diff] [review]
Make the shell exit with EXITCODE_RUNTIME_ERROR when code is terminated.

Thanks!

I'd even be OK with a bigger change in behavior here, where a single failing -e or -f causes Process to return false, and its caller checks the return value and bails out. Separate bug if so.
Comment 3 Jim Blandy :jimb 2012-01-26 23:45:17 PST
(In reply to Jason Orendorff [:jorendorff] from comment #2)
> I'd even be OK with a bigger change in behavior here, where a single failing
> -e or -f causes Process to return false, and its caller checks the return
> value and bails out. Separate bug if so.

Actually, every caller of Process already checks gExitCode, so that is the behavior this patch brings about.
Comment 4 Jim Blandy :jimb 2012-01-26 23:58:11 PST
try: https://tbpl.mozilla.org/?tree=Try&rev=6914ca5efbd0
Comment 6 Phil Ringnalda (:philor) 2012-01-29 11:08:12 PST
https://hg.mozilla.org/mozilla-central/rev/ab3edf81a46f

Note You need to log in before you can comment on or make changes to this bug.