Add support for notifications when stdin is closed

This commit is contained in:
Michael Santos
2014-11-01 16:28:33 -04:00
parent c010cf65d4
commit b50a592858
2 changed files with 12 additions and 0 deletions

View File

@@ -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;

View File

@@ -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);
}