Browse Source

Cleanup pid file handling.

Georgi Chorbadzhiyski 12 years ago
parent
commit
9050b0c8b3
2 changed files with 5 additions and 10 deletions
  1. 1
    2
      data.h
  2. 4
    8
      tsdecrypt.c

+ 1
- 2
data.h View File

@@ -229,8 +229,7 @@ struct ts {
229 229
 	int					syslog_active;
230 230
 	int					syslog_remote;
231 231
 
232
-	int					daemonize;
233
-	char				pidfile[PATH_MAX];
232
+	char				*pidfile;
234 233
 
235 234
 	enum CA_system		req_CA_sys;
236 235
 

+ 4
- 8
tsdecrypt.c View File

@@ -285,9 +285,7 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
285 285
 				ts->ident[sizeof(ts->ident) - 1] = 0;
286 286
 				break;
287 287
 			case 'd':
288
-				strncpy(ts->pidfile, optarg, sizeof(ts->pidfile) - 1);
289
-				ts->pidfile[sizeof(ts->pidfile) - 1] = 0;
290
-				ts->daemonize = 1;
288
+				ts->pidfile = optarg;
291 289
 				break;
292 290
 			case 'N':
293 291
 				strncpy(ts->notify_program, optarg, sizeof(ts->notify_program) - 1);
@@ -507,10 +505,8 @@ static void parse_options(struct ts *ts, int argc, char **argv) {
507 505
 
508 506
 	ts_LOGf("Ident      : %s\n", ts->ident[0] ? ts->ident : "*NOT SET*");
509 507
 	ts_LOGf("Notify prog: %s\n", ts->notify_program[0] ? ts->notify_program : "*NOT SET*");
510
-	if (ts->pidfile[0])
508
+	if (ts->pidfile)
511 509
 		ts_LOGf("Daemonize  : %s pid file.\n", ts->pidfile);
512
-	else
513
-		ts_LOGf("Daemonize  : no daemon\n");
514 510
 	if (ts->syslog_active) {
515 511
 		if (ts->syslog_remote)
516 512
 			ts_LOGf("Syslog     : %s:%d\n", ts->syslog_host, ts->syslog_port);
@@ -715,7 +711,7 @@ int main(int argc, char **argv) {
715 711
 
716 712
 	parse_options(&ts, argc, argv);
717 713
 
718
-	if (ts.pidfile[0])
714
+	if (ts.pidfile)
719 715
 		daemonize(ts.pidfile);
720 716
 
721 717
 	if (!ts.syslog_active) {
@@ -836,7 +832,7 @@ EXIT:
836 832
 	if (ts.input_dump_file)
837 833
 		fclose(ts.input_dump_file);
838 834
 
839
-	if (ts.daemonize)
835
+	if (ts.pidfile)
840 836
 		unlink(ts.pidfile);
841 837
 
842 838
 	notify_free(&ts.notify);

Loading…
Cancel
Save