Safeguarded dup2 and close sequence in getcmd
This commit is contained in:
parent
d4a726ad78
commit
e6844edbf1
10
dwmblocks.c
10
dwmblocks.c
|
@ -81,11 +81,13 @@ getcmd(Block *block, int sigval)
|
||||||
case 0:
|
case 0:
|
||||||
close(ConnectionNumber(dpy));
|
close(ConnectionNumber(dpy));
|
||||||
close(fd[0]);
|
close(fd[0]);
|
||||||
if (dup2(fd[1], STDOUT_FILENO) != STDOUT_FILENO) {
|
if (fd[1] != STDOUT_FILENO) {
|
||||||
perror("getcmd - child - dup2");
|
if (dup2(fd[1], STDOUT_FILENO) != STDOUT_FILENO) {
|
||||||
exit(1);
|
perror("getcmd - child - dup2");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
close(fd[1]);
|
||||||
}
|
}
|
||||||
close(fd[1]);
|
|
||||||
if (sigval == NILL) {
|
if (sigval == NILL) {
|
||||||
char *arg[] = { block->pathu, NULL };
|
char *arg[] = { block->pathu, NULL };
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue