Safeguarded dup2 and close sequence in getcmd

This commit is contained in:
Ashish Kumar Yadav 2020-08-24 04:19:45 +05:30
parent d4a726ad78
commit e6844edbf1

View file

@ -81,11 +81,13 @@ getcmd(Block *block, int sigval)
case 0:
close(ConnectionNumber(dpy));
close(fd[0]);
if (fd[1] != STDOUT_FILENO) {
if (dup2(fd[1], STDOUT_FILENO) != STDOUT_FILENO) {
perror("getcmd - child - dup2");
exit(1);
}
close(fd[1]);
}
if (sigval == NILL) {
char *arg[] = { block->pathu, NULL };