Skip to content

Commit

Permalink
task: dont wait keypress if shell exited with non-zero status
Browse files Browse the repository at this point in the history
Also propagate the exit status to fdexit().

See dosemu2/dosemu2#2217
  • Loading branch information
stsp committed Jun 4, 2024
1 parent a6902e7 commit 1bba19c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
4 changes: 4 additions & 0 deletions kernel/procsupt.asm
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,11 @@ reloc_call_call_p_0:
int 21h
mov ds,[cs:_DGROUP_]
jc .L_1
mov ah, 4dh ; get exit code
int 21h
push ax
call _P_0_exit
pop ax
jmp .L_2

.L_1:
Expand Down
2 changes: 1 addition & 1 deletion kernel/proto.h
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ struct int25regs;
VOID ASMCFUNC SEGM(HMA_TEXT) int2526_handler(WORD mode,__FAR(struct int25regs) r);
struct config;
VOID ASMCFUNC SEGM(HMA_TEXT) P_0(__FAR(const struct config)Config);
VOID ASMCFUNC SEGM(HMA_TEXT) P_0_exit(void);
VOID ASMCFUNC SEGM(HMA_TEXT) P_0_exit(unsigned short retcode);
VOID ASMCFUNC SEGM(HMA_TEXT) P_0_bad(void);
struct int2f12regs;
VOID ASMCFUNC SEGM(HMA_TEXT) int2F_12_handler(__FAR(struct int2f12regs) r);
Expand Down
14 changes: 9 additions & 5 deletions kernel/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -964,12 +964,16 @@ VOID ASMCFUNC P_0(const struct config FAR *Config)
p0_execblk_p = exb;
}

VOID ASMCFUNC P_0_exit(void)
VOID ASMCFUNC P_0_exit(unsigned short retcode)
{
_printf("\nShell %s exited, press any key...\n", GET_PTR(Shell));
con_flush_stdin();
read_char_stdin(0);
fdexit(0);
if (retcode == 0) {
_printf("\nShell %s exited, press any key...\n", GET_PTR(Shell));
con_flush_stdin();
read_char_stdin(0);
} else {
_printf("\nShell %s exited with code 0x%x\n", GET_PTR(Shell), retcode);
}
fdexit(retcode & 0xff);
}

VOID ASMCFUNC P_0_bad(void)
Expand Down

0 comments on commit 1bba19c

Please sign in to comment.