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

(-)collectd-2.1.0-orig/src/collectd.c (+29 lines)
Lines 16-21 Link Here
16
kstat_ctl_t *kc;
16
kstat_ctl_t *kc;
17
#endif /* HAVE_LIBKSTAT */
17
#endif /* HAVE_LIBKSTAT */
18
18
19
#define PID_PATH	"/var/run/collectd.pid"
20
21
19
void sigIntHandler (int signal)
22
void sigIntHandler (int signal)
20
{
23
{
21
	loop++;
24
	loop++;
Lines 166-171 Link Here
166
	exit (0);
169
	exit (0);
167
}
170
}
168
171
172
static int create_pidfile (void)
173
{
174
	FILE *fh = fopen (PID_PATH, "w");
175
	
176
	if (!fh)
177
	{
178
		syslog (LOG_ERR, "fopen (pidfile): %s", strerror (errno));
179
		return 1;
180
	}
181
	
182
	fprintf(fh, "%d\n", getpid());
183
	fclose(fh);
184
	
185
	return 0;
186
}
187
188
static int remove_pidfile (void)
189
{
190
	return unlink (PID_PATH);
191
}
192
169
int main (int argc, char **argv)
193
int main (int argc, char **argv)
170
{
194
{
171
	int sleepingtime;
195
	int sleepingtime;
Lines 253-258 Link Here
253
	}
277
	}
254
#endif
278
#endif
255
279
280
	if (create_pidfile ())
281
		exit (2);
282
256
	/* child */
283
	/* child */
257
	while (loop == 0)
284
	while (loop == 0)
258
	{
285
	{
Lines 304-309 Link Here
304
331
305
	/* close syslog */
332
	/* close syslog */
306
	closelog ();
333
	closelog ();
334
	
335
	remove_pidfile();
307
336
308
	return (0);
337
	return (0);
309
}
338
}

Return to bug 107076