#include <errno.h>
#include <signal.h>
#include <unistd.h>
+#include <syslog.h>
#include "libsysfs/sysfs/libsysfs.h"
#include "udev_libc_wrapper.h"
#include "udev.h"
#include "udev_utils.h"
-#include "udev_sysfs.h"
#include "udev_version.h"
#include "udev_rules.h"
#include "logging.h"
const char *devpath;
const char *subsystem;
struct sigaction act;
+ int devnull;
int retval = -EINVAL;
if (argc == 2 && strcmp(argv[1], "-V") == 0) {
exit(0);
}
+ /* 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);
+ }
+
logging_init("udev");
+ if (devnull < 0)
+ err("fatal, could not open /dev/null: %s", strerror(errno));
udev_init_config();
dbg("version %s", UDEV_VERSION);
if (strncmp(name_loop->name, "socket:", strlen("socket:")) == 0)
pass_env_to_socket(&name_loop->name[strlen("socket:")], devpath, action);
else
- execute_program(name_loop->name, udev.subsystem, NULL, 0, NULL);
+ run_program(name_loop->name, udev.subsystem, NULL, 0, NULL, (udev_log_priority >= LOG_INFO));
}
}
+ udev_rules_close(&rules);
udev_cleanup_device(&udev);
exit: