Changeset 12 for trunk

Show
Ignore:
Timestamp:
02/14/06 17:57:20 (17 years ago)
Author:
andreu
Message:

fix argv problem

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/renetcolSender.c

    r8 r12  
    3232RulesPtr rulesListPtr; 
    3333char *rulesFileName; 
     34char *keyId; 
    3435char *remoteHost; 
    3536int i=0; 
     
    302303  }   
    303304 
    304 /*   chdir ("/"); */ 
    305   fprintf(stderr, "I become a deamon, next messages via syslogd.\n"); 
    306   if (fork () != 0) 
    307     exit (0); 
    308   if (setsid() == -1){ 
    309     exit(4); 
    310   } 
    311 /*   for (i = 0; i < FOPEN_MAX; i ++) */ 
    312 /*     close (i); */ 
    313  
    314305  openlog(argv[0], LOG_PID, LOG_USER); 
     306  keyId = (char *) malloc((strlen(argv[1])+1) * sizeof(char)); 
     307  strcpy (keyId, argv[1]); 
    315308  rulesFileName = (char *) malloc((strlen(argv[3])+1) * sizeof(char)); 
    316309  strcpy (rulesFileName, argv[3]); 
     
    326319  tmp = NULL; 
    327320  /* get IPC messages queue */ 
    328   if ((myKey = ftok(argv[1], 0))== -1){ 
     321  if ((myKey = ftok(keyId, 0))== -1){ 
    329322    syslog(LOG_ERR, "ftok : %s", strerror(errno)); 
    330323    exit(1); 
     
    334327    exit(1); 
    335328  } 
     329 
     330/*   chdir ("/"); */ 
     331  fprintf(stderr, "I become a deamon, next messages via syslogd.\n"); 
     332  if (fork () != 0) 
     333    exit (0); 
     334  if (setsid() == -1){ 
     335    exit(4); 
     336  } 
     337/*   for (i = 0; i < FOPEN_MAX; i ++) */ 
     338/*     close (i); */ 
    336339   
    337340  /* launch a TCP server to listen remote clients */