1
0
mirror of https://github.com/systemd/systemd.git synced 2025-08-24 09:49:49 +03:00

[PATCH] udevd exit path cleanup

This commit is contained in:
kay.sievers@vrfy.org
2004-11-23 03:28:41 +01:00
committed by Greg KH
parent 8825e9e71b
commit ec9cc0127d

19
udevd.c
View File

@ -419,7 +419,7 @@ int main(int argc, char *argv[], char *envp[])
if (getuid() != 0) { if (getuid() != 0) {
dbg("need to be root, exit"); dbg("need to be root, exit");
_exit(1); goto exit;
} }
/* make sure we don't lock any path */ /* make sure we don't lock any path */
@ -430,7 +430,7 @@ int main(int argc, char *argv[], char *envp[])
fd = open( "/dev/null", O_RDWR ); fd = open( "/dev/null", O_RDWR );
if ( fd < 0 ) { if ( fd < 0 ) {
dbg("error opening /dev/null %s", strerror(errno)); dbg("error opening /dev/null %s", strerror(errno));
exit(1); goto exit;
} }
dup2(fd, 0); dup2(fd, 0);
dup2(fd, 1); dup2(fd, 1);
@ -445,29 +445,29 @@ int main(int argc, char *argv[], char *envp[])
retval = pipe(pipefds); retval = pipe(pipefds);
if (retval < 0) { if (retval < 0) {
dbg("error getting pipes: %s", strerror(errno)); dbg("error getting pipes: %s", strerror(errno));
exit(1); goto exit;
} }
retval = fcntl(pipefds[0], F_SETFL, O_NONBLOCK); retval = fcntl(pipefds[0], F_SETFL, O_NONBLOCK);
if (retval < 0) { if (retval < 0) {
dbg("error fcntl on read pipe: %s", strerror(errno)); dbg("error fcntl on read pipe: %s", strerror(errno));
exit(1); goto exit;
} }
retval = fcntl(pipefds[0], F_SETFD, FD_CLOEXEC); retval = fcntl(pipefds[0], F_SETFD, FD_CLOEXEC);
if (retval < 0) { if (retval < 0) {
dbg("error fcntl on read pipe: %s", strerror(errno)); dbg("error fcntl on read pipe: %s", strerror(errno));
exit(1); goto exit;
} }
retval = fcntl(pipefds[1], F_SETFL, O_NONBLOCK); retval = fcntl(pipefds[1], F_SETFL, O_NONBLOCK);
if (retval < 0) { if (retval < 0) {
dbg("error fcntl on write pipe: %s", strerror(errno)); dbg("error fcntl on write pipe: %s", strerror(errno));
exit(1); goto exit;
} }
retval = fcntl(pipefds[1], F_SETFD, FD_CLOEXEC); retval = fcntl(pipefds[1], F_SETFD, FD_CLOEXEC);
if (retval < 0) { if (retval < 0) {
dbg("error fcntl on write pipe: %s", strerror(errno)); dbg("error fcntl on write pipe: %s", strerror(errno));
exit(1); goto exit;
} }
/* set signal handlers */ /* set signal handlers */
@ -488,13 +488,14 @@ int main(int argc, char *argv[], char *envp[])
udevsendsock = socket(AF_LOCAL, SOCK_DGRAM, 0); udevsendsock = socket(AF_LOCAL, SOCK_DGRAM, 0);
if (udevsendsock == -1) { if (udevsendsock == -1) {
dbg("error getting socket, exit"); dbg("error getting socket, exit");
exit(1); goto exit;
} }
/* the bind takes care of ensuring only one copy running */ /* the bind takes care of ensuring only one copy running */
retval = bind(udevsendsock, (struct sockaddr *) &saddr, addrlen); retval = bind(udevsendsock, (struct sockaddr *) &saddr, addrlen);
if (retval < 0) { if (retval < 0) {
dbg("bind failed, exit"); dbg("bind failed, exit");
close(udevsendsock);
goto exit; goto exit;
} }
@ -549,8 +550,8 @@ int main(int argc, char *argv[], char *envp[])
exec_queue_manager(); exec_queue_manager();
} }
} }
exit: exit:
close(udevsendsock);
logging_close(); logging_close();
return 1; return 1;
} }