Skip to content

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

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

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inc/uutilsdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ LispPTR unix_username(LispPTR *args);
LispPTR unix_getparm(LispPTR *args);
LispPTR unix_getenv(LispPTR *args);
LispPTR unix_fullname(LispPTR *args);
LispPTR suspend_lisp(LispPTR *args);
LispPTR suspend_lisp(void);
#endif
2 changes: 1 addition & 1 deletion inc/vmemsavedefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
int lispstringP(LispPTR Lisp);
LispPTR vmem_save(char *sysout_file_name);
LispPTR vmem_save0(LispPTR *args);
void lisp_finish(void);
void lisp_finish(int exit_status);
#endif
20 changes: 11 additions & 9 deletions src/subr.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
/***********************************************************/

#include <stdio.h> // for printf, sprintf, NULL
#include <stdlib.h> // for EXIT_FAILURE, EXIT_SUCCESS
#include <time.h> // for nanosleep, timespec
#include "adr68k.h" // for NativeAligned2FromLAddr, NativeAligned4FromLAddr
#include "arith.h" // for N_GETNUMBER, ARITH_SWITCH
Expand Down Expand Up @@ -412,16 +413,17 @@ void OP_subrcall(int subr_no, int argnum) {
break;

case sb_LISPFINISH:
case sb_LISP_FINISH:
case sb_LISP_FINISH: {
int status;
POP_SUBR_ARGS;
if ((argnum > 0) && (args[0] == S_POSITIVE))
/* 8/03/88 This branch impossible to take, subr has no args */
{
TopOfStack = suspend_lisp(args);
} else
lisp_finish();
if (argnum == 0 || args[0] == NIL || args[0] == ATOM_T)
lisp_finish(EXIT_SUCCESS);
N_GETNUMBER(args[0], status, exit_fail);
lisp_finish(status);
exit_fail:
lisp_finish(EXIT_FAILURE);
break;

}
case sb_NEWPAGE:
POP_SUBR_ARGS;
TopOfStack = newpage(args[0]);
Expand Down Expand Up @@ -589,7 +591,7 @@ void OP_subrcall(int subr_no, int argnum) {
case sb_SUSPEND_LISP:
POP_SUBR_ARGS;
/* Suspend Maiko */
TopOfStack = suspend_lisp(args);
TopOfStack = suspend_lisp();
break;

case sb_MONITOR_CONTROL:
Expand Down
2 changes: 1 addition & 1 deletion src/uutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ LispPTR unix_fullname(LispPTR *args) {
extern DLword *EmMouseX68K, *EmMouseY68K, *EmKbdAd068K, *EmRealUtilin68K, *EmUtilin68K;
extern DLword *EmKbdAd168K, *EmKbdAd268K, *EmKbdAd368K, *EmKbdAd468K, *EmKbdAd568K;

LispPTR suspend_lisp(LispPTR *args) {
LispPTR suspend_lisp(void) {
#ifndef DOS
extern DLword *CTopKeyevent;
extern LispPTR *KEYBUFFERING68k;
Expand Down
4 changes: 2 additions & 2 deletions src/vmemsave.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ LispPTR vmem_save(char *sysout_file_name)

/* Make sure that we kill off any Unix subprocesses before we go away */

void lisp_finish(void) {
void lisp_finish(int exit_status) {
char d[4];

DBPRINT(("finish lisp_finish\n"));
Expand All @@ -536,5 +536,5 @@ void lisp_finish(void) {
#ifdef DOS
exit_host_filesystem();
#endif /* DOS */
exit(0);
exit(exit_status);
}