Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 107076 | Differences between
and this patch

Collapse All | Expand All

(-)src/collectd.c (-1 / +26 lines)
Lines 16-21 Link Here
16
int   num_pinghosts = 0;
16
int   num_pinghosts = 0;
17
#endif
17
#endif
18
18
19
#define PID_PATH       "/var/run/collectd.pid"
20
19
/*
21
/*
20
 * exported variables
22
 * exported variables
21
 */
23
 */
Lines 133-139 Link Here
133
		return (-1);
135
		return (-1);
134
	}
136
	}
135
#endif
137
#endif
136
138
       if (create_pidfile ())
139
               exit (2);       
137
	plugin_init_all ();
140
	plugin_init_all ();
138
141
139
	while (loop == 0)
142
	while (loop == 0)
Lines 163-168 Link Here
163
	char *instance;
166
	char *instance;
164
	char *values;
167
	char *values;
165
168
169
       if (create_pidfile ())
170
               exit (2);       
171
166
	while (loop == 0)
172
	while (loop == 0)
167
	{
173
	{
168
		if (multicast_receive (&host, &type, &instance, &values) == 0)
174
		if (multicast_receive (&host, &type, &instance, &values) == 0)
Lines 177-182 Link Here
177
	return (0);
183
	return (0);
178
}
184
}
179
185
186
int create_pidfile (void)
187
{
188
      FILE *fh = fopen (PID_PATH, "w");
189
       if (!fh)
190
       {
191
               syslog (LOG_ERR, "fopen (pidfile): %s", strerror (errno));
192
              return 1;
193
       }
194
       fprintf(fh, "%d\n", getpid());
195
       fclose(fh);
196
       return 0;
197
}
198
199
int remove_pidfile (void)
200
{
201
      return unlink (PID_PATH);
202
}
203
180
int main (int argc, char **argv)
204
int main (int argc, char **argv)
181
{
205
{
182
	struct sigaction sigIntAction, sigChldAction;
206
	struct sigaction sigIntAction, sigChldAction;
Lines 324-329 Link Here
324
	 */
348
	 */
325
	syslog (LOG_INFO, "Exiting normally");
349
	syslog (LOG_INFO, "Exiting normally");
326
	closelog ();
350
	closelog ();
351
	remove_pidfile();
327
352
328
	return (0);
353
	return (0);
329
}
354
}

Return to bug 107076