- /* get state of ipc queue */
- tspec.tv_sec = 0;
- tspec.tv_nsec = 10000000; /* 10 millisec */
- loop = 20;
- while (loop--) {
- retval = msgctl(msgid, IPC_STAT, &msg_queue);
- if (retval == -1) {
- dbg("error getting info on ipc queue");
+ set_cloexec_flag(sock, 1);
+
+ memset(&saddr, 0x00, sizeof(struct sockaddr_un));
+ 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;
+
+ memset(&msg, 0x00, sizeof(struct hotplug_msg));
+ strcpy(msg.magic, UDEV_MAGIC);
+ msg.seqnum = seq;
+ strfieldcpy(msg.action, action);
+ strfieldcpy(msg.devpath, devpath);
+ strfieldcpy(msg.subsystem, subsystem);
+
+ /* If we can't send, try to start daemon and resend message */
+ loop = SEND_WAIT_MAX_SECONDS * SEND_WAIT_LOOP_PER_SECOND;
+ while (--loop) {
+ retval = sendto(sock, &msg, sizeof(struct hotplug_msg), 0,
+ (struct sockaddr *)&saddr, addrlen);
+ if (retval != -1) {
+ retval = 0;