2 * Copyright (c) 2002-2010 M. Warner Losh.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * my_system is a variation on lib/libc/stdlib/system.c:
28 * Copyright (c) 1988, 1993
29 * The Regents of the University of California. All rights reserved.
31 * Redistribution and use in source and binary forms, with or without
32 * modification, are permitted provided that the following conditions
34 * 1. Redistributions of source code must retain the above copyright
35 * notice, this list of conditions and the following disclaimer.
36 * 2. Redistributions in binary form must reproduce the above copyright
37 * notice, this list of conditions and the following disclaimer in the
38 * documentation and/or other materials provided with the distribution.
39 * 4. Neither the name of the University nor the names of its contributors
40 * may be used to endorse or promote products derived from this software
41 * without specific prior written permission.
43 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
57 * DEVD control daemon.
61 // o devd.conf and devd man pages need a lot of help:
62 // - devd needs to document the unix domain socket
63 // - devd.conf needs more details on the supported statements.
65 #include <sys/cdefs.h>
66 __FBSDID("$FreeBSD$");
68 #include <sys/param.h>
69 #include <sys/socket.h>
71 #include <sys/sysctl.h>
72 #include <sys/types.h>
100 #include "devd.h" /* C compatible definitions */
101 #include "devd.hh" /* C++ class definitions */
103 #define STREAMPIPE "/var/run/devd.pipe"
104 #define SEQPACKETPIPE "/var/run/devd.seqpacket.pipe"
105 #define CF "/etc/devd.conf"
106 #define SYSCTL "hw.bus.devctl_queue"
109 * Since the client socket is nonblocking, we must increase its send buffer to
110 * handle brief event storms. On FreeBSD, AF_UNIX sockets don't have a receive
111 * buffer, so the client can't increate the buffersize by itself.
113 * For example, when creating a ZFS pool, devd emits one 165 character
114 * resource.fs.zfs.statechange message for each vdev in the pool. A 64k
115 * buffer has enough space for almost 400 drives, which would be very large but
116 * not impossibly large pool. A 128k buffer has enough space for 794 drives,
117 * which is more than can fit in a rack with modern technology.
119 #define CLIENT_BUFSIZE 131072
123 typedef struct client {
131 static const char notify = '!';
132 static const char nomatch = '?';
133 static const char attach = '+';
134 static const char detach = '-';
136 static struct pidfh *pfh;
138 static int no_daemon = 0;
139 static int daemonize_quick = 0;
140 static int quiet_mode = 0;
141 static unsigned total_events = 0;
142 static volatile sig_atomic_t got_siginfo = 0;
143 static volatile sig_atomic_t romeo_must_die = 0;
145 static const char *configfile = CF;
147 static void devdlog(int priority, const char* message, ...)
149 static void event_loop(void);
150 static void usage(void);
152 template <class T> void
153 delete_and_clear(vector<T *> &v)
155 typename vector<T *>::const_iterator i;
157 for (i = v.begin(); i != v.end(); ++i)
164 event_proc::event_proc() : _prio(-1)
169 event_proc::~event_proc()
171 delete_and_clear(_epsvec);
175 event_proc::add(eps *eps)
177 _epsvec.push_back(eps);
181 event_proc::matches(config &c) const
183 vector<eps *>::const_iterator i;
185 for (i = _epsvec.begin(); i != _epsvec.end(); ++i)
186 if (!(*i)->do_match(c))
192 event_proc::run(config &c) const
194 vector<eps *>::const_iterator i;
196 for (i = _epsvec.begin(); i != _epsvec.end(); ++i)
197 if (!(*i)->do_action(c))
202 action::action(const char *cmd)
214 my_system(const char *command)
218 struct sigaction ign, intact, quitact;
219 sigset_t newsigblock, oldsigblock;
221 if (!command) /* just checking... */
225 * Ignore SIGINT and SIGQUIT, block SIGCHLD. Remember to save
226 * existing signal dispositions.
228 ign.sa_handler = SIG_IGN;
229 ::sigemptyset(&ign.sa_mask);
231 ::sigaction(SIGINT, &ign, &intact);
232 ::sigaction(SIGQUIT, &ign, &quitact);
233 ::sigemptyset(&newsigblock);
234 ::sigaddset(&newsigblock, SIGCHLD);
235 ::sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock);
236 switch (pid = ::fork()) {
241 * Restore original signal dispositions and exec the command.
243 ::sigaction(SIGINT, &intact, NULL);
244 ::sigaction(SIGQUIT, &quitact, NULL);
245 ::sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
247 * Close the PID file, and all other open descriptors.
248 * Inherit std{in,out,err} only.
252 ::execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL);
254 default: /* parent */
257 pid = ::wait4(savedpid, &pstat, 0, (struct rusage *)0);
258 } while (pid == -1 && errno == EINTR);
261 ::sigaction(SIGINT, &intact, NULL);
262 ::sigaction(SIGQUIT, &quitact, NULL);
263 ::sigprocmask(SIG_SETMASK, &oldsigblock, NULL);
264 return (pid == -1 ? -1 : pstat);
268 action::do_action(config &c)
270 string s = c.expand_string(_cmd.c_str());
271 devdlog(LOG_INFO, "Executing '%s'\n", s.c_str());
272 my_system(s.c_str());
276 match::match(config &c, const char *var, const char *re) :
279 _re(c.expand_string(_inv ? re + 1 : re, "^", "$"))
281 regcomp(&_regex, _re.c_str(), REG_EXTENDED | REG_NOSUB | REG_ICASE);
290 match::do_match(config &c)
292 const string &value = c.get_variable(_var);
296 * This function gets called WAY too often to justify calling syslog()
297 * each time, even at LOG_DEBUG. Because if syslogd isn't running, it
298 * can consume excessive amounts of systime inside of connect(). Only
299 * log when we're in -d mode.
302 devdlog(LOG_DEBUG, "Testing %s=%s against %s, invert=%d\n",
303 _var.c_str(), value.c_str(), _re.c_str(), _inv);
306 retval = (regexec(&_regex, value.c_str(), 0, NULL, 0) == 0);
308 retval = (retval == 0) ? 1 : 0;
313 #include <sys/sockio.h>
315 #include <net/if_media.h>
317 media::media(config &, const char *var, const char *type)
318 : _var(var), _type(-1)
320 static struct ifmedia_description media_types[] = {
321 { IFM_ETHER, "Ethernet" },
322 { IFM_TOKEN, "Tokenring" },
323 { IFM_FDDI, "FDDI" },
324 { IFM_IEEE80211, "802.11" },
329 for (int i = 0; media_types[i].ifmt_string != NULL; ++i)
330 if (strcasecmp(type, media_types[i].ifmt_string) == 0) {
331 _type = media_types[i].ifmt_word;
341 media::do_match(config &c)
344 struct ifmediareq ifmr;
348 // Since we can be called from both a device attach/detach
349 // context where device-name is defined and what we want,
350 // as well as from a link status context, where subsystem is
351 // the name of interest, first try device-name and fall back
352 // to subsystem if none exists.
353 value = c.get_variable("device-name");
355 value = c.get_variable("subsystem");
356 devdlog(LOG_DEBUG, "Testing media type of %s against 0x%x\n",
357 value.c_str(), _type);
361 s = socket(PF_INET, SOCK_DGRAM, 0);
363 memset(&ifmr, 0, sizeof(ifmr));
364 strncpy(ifmr.ifm_name, value.c_str(), sizeof(ifmr.ifm_name));
366 if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) >= 0 &&
367 ifmr.ifm_status & IFM_AVALID) {
368 devdlog(LOG_DEBUG, "%s has media type 0x%x\n",
369 value.c_str(), IFM_TYPE(ifmr.ifm_active));
370 retval = (IFM_TYPE(ifmr.ifm_active) == _type);
371 } else if (_type == -1) {
372 devdlog(LOG_DEBUG, "%s has unknown media type\n",
382 const string var_list::bogus = "_$_$_$_$_B_O_G_U_S_$_$_$_$_";
383 const string var_list::nothing = "";
386 var_list::get_variable(const string &var) const
388 map<string, string>::const_iterator i;
391 if (i == _vars.end())
392 return (var_list::bogus);
397 var_list::is_set(const string &var) const
399 return (_vars.find(var) != _vars.end());
403 var_list::set_variable(const string &var, const string &val)
406 * This function gets called WAY too often to justify calling syslog()
407 * each time, even at LOG_DEBUG. Because if syslogd isn't running, it
408 * can consume excessive amounts of systime inside of connect(). Only
409 * log when we're in -d mode.
412 devdlog(LOG_DEBUG, "setting %s=%s\n", var.c_str(), val.c_str());
420 delete_and_clear(_var_list_table);
421 delete_and_clear(_attach_list);
422 delete_and_clear(_detach_list);
423 delete_and_clear(_nomatch_list);
424 delete_and_clear(_notify_list);
428 config::parse_one_file(const char *fn)
430 devdlog(LOG_DEBUG, "Parsing %s\n", fn);
431 yyin = fopen(fn, "r");
433 err(1, "Cannot open config file %s", fn);
436 errx(1, "Cannot parse %s at line %d", fn, lineno);
441 config::parse_files_in_dir(const char *dirname)
447 devdlog(LOG_DEBUG, "Parsing files in %s\n", dirname);
448 dirp = opendir(dirname);
451 readdir(dirp); /* Skip . */
452 readdir(dirp); /* Skip .. */
453 while ((dp = readdir(dirp)) != NULL) {
454 if (strcmp(dp->d_name + dp->d_namlen - 5, ".conf") == 0) {
455 snprintf(path, sizeof(path), "%s/%s",
456 dirname, dp->d_name);
457 parse_one_file(path);
465 int operator()(event_proc *const&l1, event_proc *const&l2) const
467 return (l1->get_priority() > l2->get_priority());
472 config::sort_vector(vector<event_proc *> &v)
474 stable_sort(v.begin(), v.end(), epv_greater());
480 vector<string>::const_iterator i;
482 parse_one_file(configfile);
483 for (i = _dir_list.begin(); i != _dir_list.end(); ++i)
484 parse_files_in_dir((*i).c_str());
485 sort_vector(_attach_list);
486 sort_vector(_detach_list);
487 sort_vector(_nomatch_list);
488 sort_vector(_notify_list);
492 config::open_pidfile()
496 if (_pidfile.empty())
498 pfh = pidfile_open(_pidfile.c_str(), 0600, &otherpid);
501 errx(1, "devd already running, pid: %d", (int)otherpid);
502 warn("cannot open pid file");
507 config::write_pidfile()
514 config::close_pidfile()
521 config::remove_pidfile()
528 config::add_attach(int prio, event_proc *p)
530 p->set_priority(prio);
531 _attach_list.push_back(p);
535 config::add_detach(int prio, event_proc *p)
537 p->set_priority(prio);
538 _detach_list.push_back(p);
542 config::add_directory(const char *dir)
544 _dir_list.push_back(string(dir));
548 config::add_nomatch(int prio, event_proc *p)
550 p->set_priority(prio);
551 _nomatch_list.push_back(p);
555 config::add_notify(int prio, event_proc *p)
557 p->set_priority(prio);
558 _notify_list.push_back(p);
562 config::set_pidfile(const char *fn)
568 config::push_var_table()
573 _var_list_table.push_back(vl);
574 devdlog(LOG_DEBUG, "Pushing table\n");
578 config::pop_var_table()
580 delete _var_list_table.back();
581 _var_list_table.pop_back();
582 devdlog(LOG_DEBUG, "Popping table\n");
586 config::set_variable(const char *var, const char *val)
588 _var_list_table.back()->set_variable(var, val);
592 config::get_variable(const string &var)
594 vector<var_list *>::reverse_iterator i;
596 for (i = _var_list_table.rbegin(); i != _var_list_table.rend(); ++i) {
597 if ((*i)->is_set(var))
598 return ((*i)->get_variable(var));
600 return (var_list::nothing);
604 config::is_id_char(char ch) const
606 return (ch != '\0' && (isalpha(ch) || isdigit(ch) || ch == '_' ||
611 config::expand_one(const char *&src, string &dst)
624 // Not sure if I want to support this or not, so for now we just pass
629 /* If the string ends before ) is matched , return. */
630 while (count > 0 && *src) {
633 else if (*src == '(')
641 if (!isalpha(*src)) {
647 // $var -> replace with value
650 } while (is_id_char(*src));
651 dst.append(get_variable(buffer));
655 config::expand_string(const char *src, const char *prepend, const char *append)
661 * 128 bytes is enough for 2427 of 2438 expansions that happen
662 * while parsing config files, as tested on 2013-01-30.
670 var_at = strchr(src, '$');
671 if (var_at == NULL) {
675 dst.append(src, var_at - src);
677 expand_one(src, dst);
687 config::chop_var(char *&buffer, char *&lhs, char *&rhs) const
693 walker = lhs = buffer;
694 while (is_id_char(*walker))
699 if (*walker == '"') {
702 while (*walker && *walker != '"')
710 while (*walker && !isspace(*walker))
716 while (isspace(*walker))
724 config::set_vars(char *buffer)
730 if (!chop_var(buffer, lhs, rhs))
732 set_variable(lhs, rhs);
738 config::find_and_execute(char type)
740 vector<event_proc *> *l;
741 vector<event_proc *>::const_iterator i;
764 devdlog(LOG_DEBUG, "Processing %s event\n", s);
765 for (i = l->begin(); i != l->end(); ++i) {
766 if ((*i)->matches(*this)) {
776 process_event(char *buffer)
782 devdlog(LOG_INFO, "Processing event '%s'\n", buffer);
784 cfg.push_var_table();
785 // No match doesn't have a device, and the format is a little
786 // different, so handle it separately.
789 sp = cfg.set_vars(sp);
792 //? at location pnp-info on bus
793 sp = strchr(sp, ' ');
795 return; /* Can't happen? */
799 if (strncmp(sp, "at ", 3) == 0)
801 sp = cfg.set_vars(sp);
804 if (strncmp(sp, "on ", 3) == 0)
805 cfg.set_variable("bus", sp + 3);
807 case attach: /*FALLTHROUGH*/
809 sp = strchr(sp, ' ');
811 return; /* Can't happen? */
813 cfg.set_variable("device-name", buffer);
816 if (strncmp(sp, "at ", 3) == 0)
818 sp = cfg.set_vars(sp);
821 if (strncmp(sp, "on ", 3) == 0)
822 cfg.set_variable("bus", sp + 3);
826 cfg.find_and_execute(type);
831 create_socket(const char *name, int socktype)
834 struct sockaddr_un sun;
836 if ((fd = socket(PF_LOCAL, socktype, 0)) < 0)
838 bzero(&sun, sizeof(sun));
839 sun.sun_family = AF_UNIX;
840 strlcpy(sun.sun_path, name, sizeof(sun.sun_path));
841 slen = SUN_LEN(&sun);
843 if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0)
845 if (::bind(fd, (struct sockaddr *) & sun, slen) < 0)
848 chown(name, 0, 0); /* XXX - root.wheel */
853 unsigned int max_clients = 10; /* Default, can be overriden on cmdline. */
854 unsigned int num_clients;
856 list<client_t> clients;
859 notify_clients(const char *data, int len)
861 list<client_t>::iterator i;
864 * Deliver the data to all clients. Throw clients overboard at the
865 * first sign of trouble. This reaps clients who've died or closed
866 * their sockets, and also clients who are alive but failing to keep up
867 * (or who are maliciously not reading, to consume buffer space in
868 * kernel memory or tie up the limited number of available connections).
870 for (i = clients.begin(); i != clients.end(); ) {
872 if (i->socktype == SOCK_SEQPACKET)
877 if (send(i->fd, data, len, flags) != len) {
880 i = clients.erase(i);
881 devdlog(LOG_WARNING, "notify_clients: send() failed; "
882 "dropping unresponsive client\n");
893 list<client_t>::iterator i;
896 * Check all existing clients to see if any of them have disappeared.
897 * Normally we reap clients when we get an error trying to send them an
898 * event. This check eliminates the problem of an ever-growing list of
899 * zombie clients because we're never writing to them on a system
900 * without frequent device-change activity.
903 for (i = clients.begin(); i != clients.end(); ) {
905 s = poll(&pfd, 1, 0);
906 if ((s < 0 && s != EINTR ) ||
907 (s > 0 && (pfd.revents & POLLHUP))) {
910 i = clients.erase(i);
911 devdlog(LOG_NOTICE, "check_clients: "
912 "dropping disconnected client\n");
919 new_client(int fd, int socktype)
925 * First go reap any zombie clients, then accept the connection, and
926 * shut down the read side to stop clients from consuming kernel memory
927 * by sending large buffers full of data we'll never read.
930 s.socktype = socktype;
931 s.fd = accept(fd, NULL, NULL);
933 sndbuf_size = CLIENT_BUFSIZE;
934 if (setsockopt(s.fd, SOL_SOCKET, SO_SNDBUF, &sndbuf_size,
935 sizeof(sndbuf_size)))
936 err(1, "setsockopt");
937 shutdown(s.fd, SHUT_RD);
938 clients.push_back(s);
949 char buffer[DEVCTL_MAXBUF];
951 int stream_fd, seqpacket_fd, max_fd;
956 fd = open(PATH_DEVCTL, O_RDONLY | O_CLOEXEC);
958 err(1, "Can't open devctl device %s", PATH_DEVCTL);
959 stream_fd = create_socket(STREAMPIPE, SOCK_STREAM);
960 seqpacket_fd = create_socket(SEQPACKETPIPE, SOCK_SEQPACKET);
962 max_fd = max(fd, max(stream_fd, seqpacket_fd)) + 1;
963 while (!romeo_must_die) {
964 if (!once && !no_daemon && !daemonize_quick) {
965 // Check to see if we have any events pending.
970 rv = select(fd + 1, &fds, &fds, &fds, &tv);
971 // No events -> we've processed all pending events
973 devdlog(LOG_DEBUG, "Calling daemon\n");
974 cfg.remove_pidfile();
982 * When we've already got the max number of clients, stop
983 * accepting new connections (don't put the listening sockets in
984 * the set), shrink the accept() queue to reject connections
985 * quickly, and poll the existing clients more often, so that we
986 * notice more quickly when any of them disappear to free up
991 if (num_clients < max_clients) {
993 listen(stream_fd, max_clients);
994 listen(seqpacket_fd, max_clients);
997 FD_SET(stream_fd, &fds);
998 FD_SET(seqpacket_fd, &fds);
1003 listen(stream_fd, 0);
1004 listen(seqpacket_fd, 0);
1010 rv = select(max_fd, &fds, NULL, NULL, &tv);
1012 devdlog(LOG_NOTICE, "Events received so far=%u\n",
1022 if (FD_ISSET(fd, &fds)) {
1023 rv = read(fd, buffer, sizeof(buffer) - 1);
1026 if (rv == sizeof(buffer) - 1) {
1027 devdlog(LOG_WARNING, "Warning: "
1028 "available event data exceeded "
1031 notify_clients(buffer, rv);
1033 while (buffer[--rv] == '\n')
1035 process_event(buffer);
1036 } else if (rv < 0) {
1044 if (FD_ISSET(stream_fd, &fds))
1045 new_client(stream_fd, SOCK_STREAM);
1047 * Aside from the socket type, both sockets use the same
1048 * protocol, so we can process clients the same way.
1050 if (FD_ISSET(seqpacket_fd, &fds))
1051 new_client(seqpacket_fd, SOCK_SEQPACKET);
1057 * functions that the parser uses.
1060 add_attach(int prio, event_proc *p)
1062 cfg.add_attach(prio, p);
1066 add_detach(int prio, event_proc *p)
1068 cfg.add_detach(prio, p);
1072 add_directory(const char *dir)
1074 cfg.add_directory(dir);
1075 free(const_cast<char *>(dir));
1079 add_nomatch(int prio, event_proc *p)
1081 cfg.add_nomatch(prio, p);
1085 add_notify(int prio, event_proc *p)
1087 cfg.add_notify(prio, p);
1091 add_to_event_proc(event_proc *ep, eps *eps)
1094 ep = new event_proc();
1100 new_action(const char *cmd)
1102 eps *e = new action(cmd);
1103 free(const_cast<char *>(cmd));
1108 new_match(const char *var, const char *re)
1110 eps *e = new match(cfg, var, re);
1111 free(const_cast<char *>(var));
1112 free(const_cast<char *>(re));
1117 new_media(const char *var, const char *re)
1119 eps *e = new media(cfg, var, re);
1120 free(const_cast<char *>(var));
1121 free(const_cast<char *>(re));
1126 set_pidfile(const char *name)
1128 cfg.set_pidfile(name);
1129 free(const_cast<char *>(name));
1133 set_variable(const char *var, const char *val)
1135 cfg.set_variable(var, val);
1136 free(const_cast<char *>(var));
1137 free(const_cast<char *>(val));
1149 * SIGINFO handler. Will print useful statistics to the syslog or stderr
1159 * Local logging function. Prints to syslog if we're daemonized; stderr
1163 devdlog(int priority, const char* fmt, ...)
1167 va_start(argp, fmt);
1169 vfprintf(stderr, fmt, argp);
1170 else if ((! quiet_mode) || (priority <= LOG_WARNING))
1171 vsyslog(priority, fmt, argp);
1178 fprintf(stderr, "usage: %s [-dnq] [-l connlimit] [-f file]\n",
1184 check_devd_enabled()
1190 if (sysctlbyname(SYSCTL, &val, &len, NULL, 0) != 0)
1191 errx(1, "devctl sysctl missing from kernel!");
1193 warnx("Setting " SYSCTL " to 1000");
1195 sysctlbyname(SYSCTL, NULL, NULL, &val, sizeof(val));
1203 main(int argc, char **argv)
1207 check_devd_enabled();
1208 while ((ch = getopt(argc, argv, "df:l:nq")) != -1) {
1214 configfile = optarg;
1217 max_clients = MAX(1, strtoul(optarg, NULL, 0));
1220 daemonize_quick = 1;
1231 if (!no_daemon && daemonize_quick) {
1234 cfg.write_pidfile();
1236 signal(SIGPIPE, SIG_IGN);
1237 signal(SIGHUP, gensighand);
1238 signal(SIGINT, gensighand);
1239 signal(SIGTERM, gensighand);
1240 signal(SIGINFO, siginfohand);