(void)signal(SIGTSTP, SIG_IGN);
(void)signal(SIGTTOU, SIG_IGN);
+ /* Set SIGCHLD to default for waitpid. */
+ (void)signal(SIGCHLD, SIG_DFL);
+
/* Create with exact permissions. */
(void)umask(0);
}
}
for (;;) {
pid = waitpid(pid, &pstat, WUNTRACED);
- if (WIFSTOPPED(pstat)) {
+ if (pid != -1 && WIFSTOPPED(pstat)) {
/* the editor suspended, so suspend us as well */
kill(getpid(), SIGSTOP);
kill(pid, SIGCONT);
break;
}
}
- if (pid == -1 || !WIFEXITED(pstat) || WEXITSTATUS(pstat) != 0)
+ if (pid == -1)
pw_error(editor, 1, 1);
+ else if (!WIFEXITED(pstat) || WEXITSTATUS(pstat) != 0) {
+ warnx("%s: unsuccessful execution", editor);
+ pw_error(editor, 0, 1);
+ }
free(editor);
}
{
if (err) {
if (name)
- warn("%s: ", name);
+ warn("%s", name);
else
warn(NULL);
}