X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=udev.c;h=507f2be943a88e9142bc802f0f4da0ac95e53aa6;hb=e4b5f339c7b63e9f67fccf2d0ef549ca34d56a7d;hp=847cc5dade49bdf177082e5f8a4ae88110e70c9d;hpb=45a7b668eca398831c0cfc39e4237494b3d603e9;p=elogind.git diff --git a/udev.c b/udev.c index 847cc5dad..507f2be94 100644 --- a/udev.c +++ b/udev.c @@ -61,6 +61,10 @@ static int manage_hotplug_event(void) { int fd; int len; + /* false, if we are called directly */ + if (!getenv("MANAGED_EVENT")) + goto exit; + fd = open("/proc/sys/kernel/hotplug", O_RDONLY); if (fd < 0) goto exit; @@ -111,17 +115,22 @@ int main(int argc, char *argv[], char *envp[]) act.sa_handler = (void (*) (int))sig_handler; sigemptyset (&act.sa_mask); act.sa_flags = 0; - /* alarm must not restart syscalls*/ sigaction(SIGALRM, &act, NULL); sigaction(SIGINT, &act, NULL); sigaction(SIGTERM, &act, NULL); - /* trigger timeout to interrupt blocking syscalls */ + /* trigger timeout to prevent hanging processes */ alarm(ALARM_TIMEOUT); + action = getenv("ACTION"); + devpath = getenv("DEVPATH"); + subsystem = getenv("SUBSYSTEM"); + /* older kernels passed the SUBSYSTEM only as argument */ + if (!subsystem && argc == 2) + subsystem = argv[1]; udev_init_device(&udev, devpath, subsystem); - if (strstr(argv[0], "udevstart") || (argv[1] != NULL && strstr(argv[1], "udevstart"))) { + if (strstr(argv[0], "udevstart") || (argc == 2 && strstr(argv[1], "udevstart"))) { dbg("udevstart"); /* disable all logging, as it's much too slow on some facilities */