-I$(LINUX_INCLUDE_DIR)
LIB_OBJS =
LDFLAGS = --static --nostdlib -nostartfiles -nodefaultlibs
- UDEVD =
else
WARNINGS += -Wshadow -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations
CRT0 =
CFLAGS += $(WARNINGS) -I$(GCCINCDIR)
LIB_OBJS = -lc
LDFLAGS =
- UDEVD = $(DAEMON)
endif
CFLAGS += -I$(PWD)/libsysfs
-all: $(ROOT) $(SENDER) $(UDEVD) $(HELPER)
+all: $(ROOT) $(SENDER) $(DAEMON) $(HELPER)
@extras="$(EXTRAS)" ; for target in $$extras ; do \
echo $$target ; \
$(MAKE) prefix=$(prefix) \
static void sig_handler(int signum)
{
- dbg("caught signal %d", signum);
switch (signum) {
case SIGINT:
case SIGTERM:
sysbus_disconnect();
udevdb_exit();
exit(20 + signum);
- break;
default:
dbg("unhandled signal");
}
char *subsystem;
int retval = -EINVAL;
int i;
+ struct sigaction act;
action = get_action();
if (!action) {
}
/* set up a default signal handler for now */
- signal(SIGINT, sig_handler);
- signal(SIGTERM, sig_handler);
+ act.sa_handler = sig_handler;
+ sigemptyset (&act.sa_mask);
+ act.sa_flags = SA_RESTART;
+ sigaction(SIGINT, &act, NULL);
+ sigaction(SIGTERM, &act, NULL);
/* initialize the naming deamon */
namedev_init();
static void udev_run(struct hotplug_msg *msg)
{
pid_t pid;
- setenv("ACTION", msg->action, 1);
- setenv("DEVPATH", msg->devpath, 1);
+ char action[32];
+ char devpath[256];
+ char *env[] = { action, devpath, NULL };
+
+ snprintf(action, sizeof(action), "ACTION=%s", msg->action);
+ snprintf(devpath, sizeof(devpath), "DEVPATH=%s", msg->devpath);
pid = fork();
switch (pid) {
case 0:
/* child */
- execl(UDEV_BIN, "udev", msg->subsystem, NULL);
+ execle(UDEV_BIN, "udev", msg->subsystem, NULL, env);
dbg("exec of child failed");
exit(1);
break;
struct sockaddr_un saddr;
socklen_t addrlen;
int retval;
+ struct sigaction act;
init_logging("udevd");
- signal(SIGINT, sig_handler);
- signal(SIGTERM, sig_handler);
- signal(SIGALRM, sig_handler);
- signal(SIGCHLD, sig_handler);
+ /* 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 */
- siginterrupt(SIGALRM, 1);
- siginterrupt(SIGCHLD, 1);
+ act.sa_flags = 0;
+ sigaction(SIGALRM, &act, NULL);
+ sigaction(SIGCHLD, &act, NULL);
memset(&saddr, 0x00, sizeof(saddr));
saddr.sun_family = AF_LOCAL;
}
/* the bind takes care of ensuring only one copy running */
- retval = bind(ssock, &saddr, addrlen);
+ retval = bind(ssock, (struct sockaddr *) &saddr, addrlen);
if (retval < 0) {
dbg("bind failed\n");
goto exit;
/* If we can't send, try to start daemon and resend message */
loop = UDEVSEND_CONNECT_RETRY;
while (loop--) {
- retval = sendto(sock, &message, size, 0, (struct sockaddr*)&saddr, addrlen);
+ retval = sendto(sock, &message, size, 0, (struct sockaddr *)&saddr, addrlen);
if (retval != -1) {
retval = 0;
goto close_and_exit;