- snprintf(string, sizeof(string), "%d\n", getpid());
- write(lock_file, string, strlen(string));
+ /* set signal handler */
+ act.sa_handler = sig_handler;
+ sigemptyset (&act.sa_mask);
+ act.sa_flags = SA_RESTART;
+ sigaction(SIGINT, &act, NULL);
+ sigaction(SIGTERM, &act, NULL);
+
+ /* we want these two to interrupt system calls */
+ act.sa_flags = 0;
+ sigaction(SIGALRM, &act, NULL);
+ sigaction(SIGCHLD, &act, NULL);
+
+ memset(&saddr, 0x00, sizeof(saddr));
+ saddr.sun_family = AF_LOCAL;
+ /* use abstract namespace for socket path */
+ strcpy(&saddr.sun_path[1], UDEVD_SOCK_PATH);
+ addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
+
+ ssock = socket(AF_LOCAL, SOCK_DGRAM, 0);
+ if (ssock == -1) {
+ dbg("error getting socket, exit");
+ exit(1);
+ }