Skip to content

Commit 31bb14b

Browse files
authored
Modifies Lisp exit subr to permit passing an exit status code (#524)
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.
1 parent f23a43f commit 31bb14b

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

inc/uutilsdefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ LispPTR unix_username(LispPTR *args);
66
LispPTR unix_getparm(LispPTR *args);
77
LispPTR unix_getenv(LispPTR *args);
88
LispPTR unix_fullname(LispPTR *args);
9-
LispPTR suspend_lisp(LispPTR *args);
9+
LispPTR suspend_lisp(void);
1010
#endif

inc/vmemsavedefs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
int lispstringP(LispPTR Lisp);
55
LispPTR vmem_save(char *sysout_file_name);
66
LispPTR vmem_save0(LispPTR *args);
7-
void lisp_finish(void);
7+
void lisp_finish(int exit_status);
88
#endif

src/subr.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
/***********************************************************/
3030

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

414415
case sb_LISPFINISH:
415-
case sb_LISP_FINISH:
416+
case sb_LISP_FINISH: {
417+
int status;
416418
POP_SUBR_ARGS;
417-
if ((argnum > 0) && (args[0] == S_POSITIVE))
418-
/* 8/03/88 This branch impossible to take, subr has no args */
419-
{
420-
TopOfStack = suspend_lisp(args);
421-
} else
422-
lisp_finish();
419+
if (argnum == 0 || args[0] == NIL || args[0] == ATOM_T)
420+
lisp_finish(EXIT_SUCCESS);
421+
N_GETNUMBER(args[0], status, exit_fail);
422+
lisp_finish(status);
423+
exit_fail:
424+
lisp_finish(EXIT_FAILURE);
423425
break;
424-
426+
}
425427
case sb_NEWPAGE:
426428
POP_SUBR_ARGS;
427429
TopOfStack = newpage(args[0]);
@@ -589,7 +591,7 @@ void OP_subrcall(int subr_no, int argnum) {
589591
case sb_SUSPEND_LISP:
590592
POP_SUBR_ARGS;
591593
/* Suspend Maiko */
592-
TopOfStack = suspend_lisp(args);
594+
TopOfStack = suspend_lisp();
593595
break;
594596

595597
case sb_MONITOR_CONTROL:

src/uutils.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ LispPTR unix_fullname(LispPTR *args) {
292292
extern DLword *EmMouseX68K, *EmMouseY68K, *EmKbdAd068K, *EmRealUtilin68K, *EmUtilin68K;
293293
extern DLword *EmKbdAd168K, *EmKbdAd268K, *EmKbdAd368K, *EmKbdAd468K, *EmKbdAd568K;
294294

295-
LispPTR suspend_lisp(LispPTR *args) {
295+
LispPTR suspend_lisp(void) {
296296
#ifndef DOS
297297
extern DLword *CTopKeyevent;
298298
extern LispPTR *KEYBUFFERING68k;

src/vmemsave.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ LispPTR vmem_save(char *sysout_file_name)
518518

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

521-
void lisp_finish(void) {
521+
void lisp_finish(int exit_status) {
522522
char d[4];
523523

524524
DBPRINT(("finish lisp_finish\n"));
@@ -536,5 +536,5 @@ void lisp_finish(void) {
536536
#ifdef DOS
537537
exit_host_filesystem();
538538
#endif /* DOS */
539-
exit(0);
539+
exit(exit_status);
540540
}

0 commit comments

Comments
 (0)