Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifies Lisp exit subr to permit passing an exit status code #524

Merged
merged 1 commit into from
Jan 16, 2025

Conversation

nbriggs
Copy link
Collaborator

@nbriggs nbriggs commented Jan 15, 2025

These changes add (LOGOUT <number>) to the traditional (LOGOUT) and (LOGOUT T) calls. If an integer <number> is provided it will be used as the exit status code, while NIL and T result in an EXIT_SUCCESS.

If the argument passed is none of NIL, T, or a number, the exit status code will be a generic EXIT_FAILURE (typically 1).

(LOGOUT) and (LOGOUT T) virtual memory behavior is unaffected. When a <number> is passed Lisp will exit without saving the virtual memory state, as is the case for (LOGOUT T), although this behavior is determined by Lisp rather than the Maiko emulator.

These changes add (LOGOUT <number>) to the traditional
(LOGOUT) and (LOGOUT T) calls.  If an integer <number> is provided
it will be used as the exit status code, while NIL and T result
in an EXIT_SUCCESS.

If the argument passed is none of NIL, T, or a number, the exit
status code will be a generic EXIT_FAILURE (typically 1).

(LOGOUT) and (LOGOUT T) virtual memory behavior is unaffected.
When a <number> is passed Lisp will exit without saving the
virtual memory state, as is the case for (LOGOUT T), although
this behavior is determined by Lisp rather than the Maiko emulator.
@nbriggs nbriggs merged commit 31bb14b into master Jan 16, 2025
@fghalasz
Copy link
Member

Adding comment late. Sorry.

Might make sense to separate the two arguments (Save/NoSave and Exit Code) in the API. The function signature would be (LOGOUT NoSave ExitCode). Default for NoSave in NIL and for ExitCode is 0. This way (LOGOUT) and (LOGOUT T) would maintain their current semantics. And you could still save vm even with an exit code (whether or not that exit code is 0).

@nbriggs
Copy link
Collaborator Author

nbriggs commented Jan 17, 2025

@fghalasz - That should be fairly easy, edits to LOGOUT and \LOGOUT0 in ADIR should do it. The current implementation doesn't change the semantics of (LOGOUT) and (LOGOUT T), you always get an exit code of 0, as you did previously -- and (LOGOUT 0) is the same as (LOGOUT T) (because 0 is not NIL, the Lisp code won't SAVEVM). I was trying to avoid changing the Lisp code, but your suggestion makes it more usable.

@nbriggs
Copy link
Collaborator Author

nbriggs commented Jan 17, 2025

@fghalasz - I can do this with compatibility between old/new Maiko and old/new sysouts -- In all cases the savevm behavior of the fast flag (NIL/T) is maintained, but note the old undocumented old behavior of fast = 0 that I'll remove, there's a separate (SUSPEND-LISP) subr for that.

New maiko:
old sysout:

  • (LOGOUT), (LOGOUT T) will exit with status 0 (EXIT_SUCCESS, as currently) because they'll (SUBRCALL LISPFINISH FAST) (arg count = 1 to SUBR)
  • (LOGOUT fast exitcode) in old sysout, same, since exitcode doesn't get passed to the SUBRCALL (arg count = 1)

new sysout:

  • (LOGOUT fast) will exit with status 0, (arg count = 2) exit code NIL => 0
  • (LOGOUT fast exitcode) exitcode is a number, will exit with status exitcode
  • (LOGOUT fast exitcode) exitcode is NOT a number, will exit with status EXIT_FAILURE (1).

For an older maiko (that knows nothing about this scheme)
either an old or new sysout:

  • (LOGOUT fast) for fast NIL or T exits with status code 0,
  • (LOGOUT 0) does a suspend rather than an exit -- this is old behavior that is undocumented
  • (LOGOUT fast exitcode) ignores exitcode, behaves as above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants