mirror of
https://github.com/uselessd/alcove.git
synced 2026-04-15 01:04:41 +00:00
Add support for notifications when stdin is closed
This commit is contained in:
@@ -631,6 +631,12 @@ exited_pid(alcove_state_t *ap, alcove_child_t *c, void *arg1, void *arg2)
|
||||
int index = 0;
|
||||
char t[MAXMSGLEN] = {0};
|
||||
|
||||
if ( (c->fdin >= 0) && (ap->opt & alcove_opt_stdin_closed)) {
|
||||
index = alcove_mk_atom(t, sizeof(t), "stdin_closed");
|
||||
if (alcove_call_fake_reply(c->pid, ALCOVE_MSG_EVENT, t, index) < 0)
|
||||
return -1;
|
||||
}
|
||||
|
||||
c->exited = 1 << 8;
|
||||
(void)close(c->fdin);
|
||||
c->fdin = -1;
|
||||
|
||||
@@ -145,6 +145,9 @@ alcove_getopt(alcove_state_t *ap, const char *arg, size_t len,
|
||||
else if (!strcmp(opt, "termsig")) {
|
||||
val = ap->opt & alcove_opt_termsig ? 1 : 0;
|
||||
}
|
||||
else if (!strcmp(opt, "stdin_closed")) {
|
||||
val = ap->opt & alcove_opt_stdin_closed ? 1 : 0;
|
||||
}
|
||||
else if (!strcmp(opt, "stdout_closed")) {
|
||||
val = ap->opt & alcove_opt_stdout_closed ? 1 : 0;
|
||||
}
|
||||
@@ -189,6 +192,9 @@ alcove_setopt(alcove_state_t *ap, const char *arg, size_t len,
|
||||
else if (!strcmp(opt, "termsig")) {
|
||||
ALCOVE_SETOPT(ap, alcove_opt_termsig, val);
|
||||
}
|
||||
else if (!strcmp(opt, "stdin_closed")) {
|
||||
ALCOVE_SETOPT(ap, alcove_opt_stdin_closed, val);
|
||||
}
|
||||
else if (!strcmp(opt, "stdout_closed")) {
|
||||
ALCOVE_SETOPT(ap, alcove_opt_stdout_closed, val);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user