Error out if dup2 doesn't return the fd we want
This commit is contained in:
parent
dfc2f7edac
commit
f308a58740
9
getty.c
9
getty.c
@ -65,9 +65,12 @@ main(int argc, char *argv[])
|
|||||||
fd = open(tty, O_RDWR);
|
fd = open(tty, O_RDWR);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
eprintf("open %s:", tty);
|
eprintf("open %s:", tty);
|
||||||
dup2(fd, STDIN_FILENO);
|
if (dup2(fd, STDIN_FILENO) != STDIN_FILENO)
|
||||||
dup2(fd, STDOUT_FILENO);
|
eprintf("dup2:");
|
||||||
dup2(fd, STDERR_FILENO);
|
if (dup2(fd, STDOUT_FILENO) != STDOUT_FILENO)
|
||||||
|
eprintf("dup2:");
|
||||||
|
if (dup2(fd, STDERR_FILENO) != STDERR_FILENO)
|
||||||
|
eprintf("dup2:");
|
||||||
|
|
||||||
sa.sa_handler = SIG_DFL;
|
sa.sa_handler = SIG_DFL;
|
||||||
sa.sa_flags = 0;
|
sa.sa_flags = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user