- /* skip blacklisted subsystems */
- subsystem = argv[1];
- i = 0;
- while (subsystem_blacklist[i][0] != '\0') {
- if (strcmp(subsystem, subsystem_blacklist[i]) == 0) {
- dbg("don't care about '%s' devices", subsystem);
- goto exit;
- }
- i++;
+ /* set std fd's to /dev/null, if the kernel forks us, we don't have them at all */
+ devnull = open("/dev/null", O_RDWR);
+ if (devnull >= 0) {
+ if (devnull != STDIN_FILENO)
+ dup2(devnull, STDIN_FILENO);
+ if (devnull != STDOUT_FILENO)
+ dup2(devnull, STDOUT_FILENO);
+ if (devnull != STDERR_FILENO)
+ dup2(devnull, STDERR_FILENO);
+ if (devnull > STDERR_FILENO)
+ close(devnull);