}
if (ch < le) {
-
strncpy(&usend_msg.envbuf[bufpos],ls,(ch - ls) + 1);
bufpos += (ch - ls) + 1;
if (ch[1] == '\'' && le[-1] == '\'') {
retval = sendto(sock, &usend_msg, usend_msg_len, 0, (struct sockaddr *)&saddr, addrlen);
if (retval < 0) {
dbg("error sending message (%s)", strerror(errno));
+ retval = -1;
}
}
-
+
return retval;
}
char *event_file = NULL;
DIR *dirstream;
struct dirent *direntry;
- int retval = 1;
+ int retval = 0;
int disable_loop_detection = 0;
int sock;
const char *env;
if (!dirstream) {
info("error opening directory %s: %s\n",
event_dir, strerror(errno));
- return 1;
+ return 2;
}
chdir(event_dir);
while ((direntry = readdir(dirstream)) != NULL) {
if (sock != -1)
close(sock);
- return retval;
+ if (retval)
+ return 3;
+ return 0;
}
if (retval < 0) {
fprintf(stderr, "bind failed, %s\n", strerror(errno));
close(udev_monitor_sock);
+ udev_monitor_sock = -1;
return -1;
}
if (getuid() != 0) {
fprintf(stderr, "need to be root, exit\n\n");
- exit(1);
+ exit(2);
}
retval = init_udev_monitor_socket();
if (retval)
goto out;
- init_uevent_netlink_sock();
+ retval = init_uevent_netlink_sock();
+ if (retval)
+ goto out;
printf("udevmonitor prints the received event from the kernel [UEVENT]\n"
"and the event which udev sends out after rule processing [UDEV]\n\n");
if (udev_monitor_sock > 0)
close(udev_monitor_sock);
- return retval;
+ if (retval)
+ return 3;
+ return 0;
}