#include <string.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <sys/stat.h>
#include <unistd.h>
+#include <fcntl.h>
+
#include "udev.h"
#include "udev_lib.h"
+#include "udevdb.h"
#include "logging.h"
#define DEVD_DIR "/etc/dev.d/"
static int run_program(char *name)
{
pid_t pid;
+ int fd;
+ char *argv[3];
dbg("running %s", name);
switch (pid) {
case 0:
/* child */
- execv(name, main_argv);
+ udevdb_exit(); /* close udevdb */
+ fd = open("/dev/null", O_RDWR);
+ if ( fd >= 0) {
+ dup2(fd, STDOUT_FILENO);
+ dup2(fd, STDIN_FILENO);
+ dup2(fd, STDERR_FILENO);
+ }
+ close(fd);
+
+ argv[0] = name;
+ argv[1] = main_argv[1];
+ argv[2] = NULL;
+
+ execv(name, argv);
dbg("exec of child failed");
exit(1);
case -1:
* subsystem/
* default/
*/
-void dev_d_send(struct udevice *dev, char *subsystem, char *devpath)
+void dev_d_send(struct udevice *dev, const char *subsystem, const char *devpath)
{
char dirname[256];
char env_devname[NAME_SIZE];
if (udev_dev_d == 0)
return;
+ memset(env_devname, 0x00, sizeof(env_devname));
if (dev->type == 'b' || dev->type == 'c') {
strfieldcpy(env_devname, udev_root);
strfieldcat(env_devname, dev->name);