else if (pid == 0) {
int fd, r;
- if ((fd = acquire_terminal("/dev/console", false, true)) < 0) {
+ if ((fd = acquire_terminal("/dev/console", false, true, true)) < 0)
log_error("Failed to acquire terminal: %s", strerror(-fd));
- _exit(1);
- }
-
- if ((r = make_stdio(fd)) < 0) {
+ else if ((r = make_stdio(fd)) < 0)
log_error("Failed to duplicate terminal fd: %s", strerror(-r));
- _exit(1);
- }
execl("/bin/sh", "/bin/sh", NULL);
static int make_null_stdio(void) {
int null_fd, r;
- if ((null_fd = open("/dev/null", O_RDWR)) < 0) {
+ if ((null_fd = open("/dev/null", O_RDWR|O_NOCTTY)) < 0) {
log_error("Failed to open /dev/null: %m");
return -errno;
}