summaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authordzwdz2024-07-25 22:17:27 +0200
committerdzwdz2024-07-25 22:17:27 +0200
commit69fd0dd9fda47aa52cccdbef6ca388cea38e693b (patch)
tree9e0e80e0380f2f39dea8f3a76ecb629918ff187a /src/cmd
parent24934406d5d39e013e22a9e6f4138c4169460d71 (diff)
kernel: pass more information to user on interrupt
This is meant to facilitate a syscall for returning from interrupts, which will actually work in the general case as opposed to the current hack, which only works if the interrupt occured during a syscall (which is correct... for now).
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/init/driver/termcook.c2
-rw-r--r--src/cmd/init/init.c7
-rw-r--r--src/cmd/shell/shell.c6
3 files changed, 10 insertions, 5 deletions
diff --git a/src/cmd/init/driver/termcook.c b/src/cmd/init/driver/termcook.c
index e0edcf5..ed851e3 100644
--- a/src/cmd/init/driver/termcook.c
+++ b/src/cmd/init/driver/termcook.c
@@ -77,7 +77,7 @@ static void line_editor(void *) {
}
break;
case 3: /* C-c */
- send_intr("");
+ send_intr("C-c");
break;
case 0x1c: /* C-\ */
send_intr("kill");
diff --git a/src/cmd/init/init.c b/src/cmd/init/init.c
index 0a64054..9caa283 100644
--- a/src/cmd/init/init.c
+++ b/src/cmd/init/init.c
@@ -68,9 +68,10 @@ void redirect(const char *exe, const char *out, const char *in) {
}
}
-void shutdown(void) {
- printf("[init] intr\n");
- _sys_intr(NULL, 0);
+void shutdown(struct intr_data *data) {
+ const char *msg = "impending shutdown";
+ printf("[init] shutdown with message: %s\n", data->msg);
+ _sys_intr(msg, strlen(msg));
_sys_sleep(1000);
printf("[init] filicide\n");
_sys_filicide();
diff --git a/src/cmd/shell/shell.c b/src/cmd/shell/shell.c
index 9afdb5c..15cb6ed 100644
--- a/src/cmd/shell/shell.c
+++ b/src/cmd/shell/shell.c
@@ -139,10 +139,14 @@ static void run(char *cmd) {
}
}
+static void intr(struct intr_data *intr) {
+ fprintf(stderr, "%s: got interrupt: %s\n", getprogname(), intr->msg);
+}
+
int main(int argc, char **argv) {
static char buf[256];
FILE *f = stdin;
- intr_set(NULL);
+ intr_set(intr);
if (argc > 1) {
f = fopen(argv[1], "r");