]> git.wh0rd.org - patches.git/blame - lirc-cvs-control-daemonize.patch
more random patches. who knows.
[patches.git] / lirc-cvs-control-daemonize.patch
CommitLineData
5e993f12 1Index: configure.ac
2===================================================================
3RCS file: /cvsroot/lirc/lirc/configure.ac,v
4retrieving revision 1.2
5diff -u -p -r1.2 configure.ac
6--- configure.ac 22 Jul 2007 07:30:25 -0000 1.2
7+++ configure.ac 24 Oct 2007 01:29:16 -0000
8@@ -42,15 +42,6 @@ AC_FUNC_VPRINTF
9 AC_CHECK_FUNCS(gethostname gettimeofday mkfifo select socket strdup \
10 strerror strtoul snprintf strsep vsyslog)
11
12-daemon=""
13-AC_CHECK_FUNCS(daemon)
14-if test "$ac_cv_func_daemon" != yes; then
15- AC_CHECK_LIB(bsd,daemon,daemon="-lbsd")
16- if test "$daemon" = ""; then
17- AC_MSG_ERROR([*** daemon() function not available on this system])
18- fi
19-fi
20-
21 forkpty=""
22 AC_CHECK_FUNCS(forkpty)
23 if test "$ac_cv_func_forkpty" != yes; then
24@@ -1468,7 +1459,17 @@ test x${enableval} = xyes && AC_DEFINE(D
25 AC_ARG_ENABLE(daemonize,
26 [ --disable-daemonize disable daemons from daemonizing],
27 test x${enableval} = xyes && AC_DEFINE(DAEMONIZE),
28-AC_DEFINE(DAEMONIZE))
29+[
30+AC_CHECK_FUNCS(daemon)
31+if test "$ac_cv_func_daemon" != yes; then
32+ daemon=""
33+ AC_CHECK_LIB(bsd,daemon,daemon="-lbsd")
34+ if test "$daemon" = ""; then
35+ AC_MSG_ERROR([*** daemon() function not available on this system and --disable-daemonize not specified])
36+ fi
37+fi
38+AC_DEFINE(DAEMONIZE)
39+])
40
41 AC_ARG_WITH(syslog,
42 [ --with-syslog=facility use syslog instead of logfile],
43Index: tools/irexec.c
44===================================================================
45RCS file: /cvsroot/lirc/lirc/tools/irexec.c,v
46retrieving revision 5.6
47diff -u -p -r5.6 irexec.c
48--- tools/irexec.c 7 Jun 2003 22:12:52 -0000 5.6
49+++ tools/irexec.c 24 Oct 2007 01:29:16 -0000
50@@ -25,11 +25,26 @@
51 #include "lirc_client.h"
52
53 char *progname;
54+struct lirc_config *config;
55+
56+void daemonize(void)
57+{
58+#ifdef DAEMONIZE
59+ if(daemon(0,0)==-1)
60+#endif
61+ {
62+ fprintf(stderr,"%s: can't daemonize\n",
63+ progname);
64+ perror(progname);
65+ lirc_freeconfig(config);
66+ lirc_deinit();
67+ exit(EXIT_FAILURE);
68+ }
69+}
70
71 int main(int argc, char *argv[])
72 {
73- struct lirc_config *config;
74- int daemonize=0;
75+ int do_daemon=0;
76 char* program="irexec";
77
78 progname="irexec " VERSION;
79@@ -60,7 +75,7 @@ int main(int argc, char *argv[])
80 printf("%s\n",progname);
81 return(EXIT_SUCCESS);
82 case 'd':
83- daemonize=1;
84+ do_daemon=1;
85 break;
86 case 'n':
87 program=optarg;
88@@ -76,7 +91,7 @@ int main(int argc, char *argv[])
89 return(EXIT_FAILURE);
90 }
91
92- if(lirc_init(program, daemonize ? 0:1)==-1) exit(EXIT_FAILURE);
93+ if(lirc_init(program, do_daemon ? 0:1)==-1) exit(EXIT_FAILURE);
94
95 if(lirc_readconfig(optind!=argc ? argv[optind]:NULL,&config,NULL)==0)
96 {
97@@ -84,18 +99,7 @@ int main(int argc, char *argv[])
98 char *c;
99 int ret;
100
101- if(daemonize)
102- {
103- if(daemon(0,0)==-1)
104- {
105- fprintf(stderr,"%s: can't daemonize\n",
106- progname);
107- perror(progname);
108- lirc_freeconfig(config);
109- lirc_deinit();
110- exit(EXIT_FAILURE);
111- }
112- }
113+ if(do_daemon) daemonize();
114 while(lirc_nextcode(&code)==0)
115 {
116 if(code==NULL) continue;
117@@ -103,7 +107,7 @@ int main(int argc, char *argv[])
118 c!=NULL)
119 {
120 #ifdef DEBUG
121- if(!daemonize)
122+ if(!do_daemon)
123 {
124 printf("Execing command \"%s\"\n",c);
125 }
126Index: tools/lircrcd.c
127===================================================================
128RCS file: /cvsroot/lirc/lirc/tools/lircrcd.c,v
129retrieving revision 5.3
130diff -u -p -r5.3 lircrcd.c
131--- tools/lircrcd.c 6 May 2006 09:40:07 -0000 5.3
132+++ tools/lircrcd.c 24 Oct 2007 01:29:17 -0000
133@@ -128,8 +128,6 @@ static int termsig;
134 static int clin=0;
135 static struct client_data clis[MAX_CLIENTS];
136
137-static int daemonized=0;
138-
139 static struct lirc_config *config;
140
141 static int send_error(int fd,char *message,char *format_str, ...);
142@@ -313,7 +311,7 @@ static void remove_client(int i)
143 void add_client(int sock)
144 {
145 int fd;
146- int clilen;
147+ socklen_t clilen;
148 struct sockaddr client_addr;
149 int flags;
150
151@@ -989,6 +987,7 @@ int main(int argc, char **argv)
152
153 /* fork */
154 getcwd(dir, sizeof(dir));
155+#ifdef DAEMONIZE
156 if(daemon(0,0)==-1)
157 {
158 fprintf(stderr, "%s: daemon() failed\n", progname);
159@@ -998,7 +997,7 @@ int main(int argc, char **argv)
160 lirc_freeconfig(config);
161 return -1;
162 }
163- daemonized=1;
164+#endif
165
166 openlog(progname, LOG_CONS|LOG_PID, LOG_USER);
167 umask(0);