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

(-)file_not_specified_in_diff (-1 / +29 lines)
Line  Link Here
0
-- collectd-3.1.0/src/collectd.c~pidfile-3.1.0
0
++ collectd-3.1.0/src/collectd.c
Lines 22-27 Link Here
22
time_t curtime;
22
time_t curtime;
23
int operating_mode;
23
int operating_mode;
24
24
25
#define PID_PATH	"/var/run/collectd.pid"
26
25
void sigIntHandler (int signal)
27
void sigIntHandler (int signal)
26
{
28
{
27
	loop++;
29
	loop++;
Lines 136-141 Link Here
136
138
137
	plugin_init_all ();
139
	plugin_init_all ();
138
140
141
	if (create_pidfile ())
142
		exit (2);	
143
139
	while (loop == 0)
144
	while (loop == 0)
140
	{
145
	{
141
		curtime = time (NULL);
146
		curtime = time (NULL);
Lines 163-168 Link Here
163
	char *instance;
168
	char *instance;
164
	char *values;
169
	char *values;
165
170
171
	if (create_pidfile ())
172
		exit (2);	
173
	
166
	while (loop == 0)
174
	while (loop == 0)
167
	{
175
	{
168
		if (multicast_receive (&host, &type, &instance, &values) == 0)
176
		if (multicast_receive (&host, &type, &instance, &values) == 0)
Lines 177-182 Link Here
177
	return (0);
185
	return (0);
178
}
186
}
179
187
188
int create_pidfile (void)
189
{
190
	FILE *fh = fopen (PID_PATH, "w");
191
	if (!fh)
192
	{
193
		syslog (LOG_ERR, "fopen (pidfile): %s", strerror (errno));
194
		return 1;
195
	}
196
	fprintf(fh, "%d\n", getpid());
197
	fclose(fh);
198
	return 0;
199
}
200
201
int remove_pidfile (void)
202
{
203
	return unlink (PID_PATH);
204
}
205
180
int main (int argc, char **argv)
206
int main (int argc, char **argv)
181
{
207
{
182
	struct sigaction sigIntAction, sigChldAction;
208
	struct sigaction sigIntAction, sigChldAction;
Lines 324-329 Link Here
324
	 */
350
	 */
325
	syslog (LOG_INFO, "Exiting normally");
351
	syslog (LOG_INFO, "Exiting normally");
326
	closelog ();
352
	closelog ();
353
	remove_pidfile();
327
354
328
	return (0);
355
	return (0);
329
}
356
}
357

Return to bug 107076