ALT Linux repos
Group :: System/Servers
RPM: irda-utils
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: irda-utils-0.9.16-alt-irattach-daemonize.patch
Download
Download
--- irda-utils-0.9.16/irattach/util.c.alt-irattach-daemonize 2004-04-01 01:55:41 +0400
+++ irda-utils-0.9.16/irattach/util.c 2006-09-02 23:47:40 +0400
@@ -158,6 +158,7 @@ void fork_now(int ttyfd)
{
int ret;
int i;
+ int fd;
if ((ret = fork()) > 0)
exit(0);
@@ -173,10 +174,23 @@ void fork_now(int ttyfd)
}
/* Close all open inherited files! Except for ttyfd! */
- for (i = 0; i < 64; i++)
+ for (i = 0; i < sysconf(_SC_OPEN_MAX); i++)
if(i != ttyfd)
close(i);
+ /* Redirect standard descriptors to /dev/null to avoid trouble */
+ fd = open("/dev/null", O_RDWR);
+ if (fd >= 0) {
+ if (fd != STDIN_FILENO)
+ dup2(fd, STDIN_FILENO);
+ if (fd != STDOUT_FILENO)
+ dup2(fd, STDOUT_FILENO);
+ if (fd != STDERR_FILENO)
+ dup2(fd, STDERR_FILENO);
+ if (fd > STDERR_FILENO)
+ close(fd);
+ }
+
write_pid();
}