debug fork
This commit is contained in:
parent
82c0754829
commit
8516ab5089
40
main.c
40
main.c
@ -180,8 +180,28 @@ int main()
|
||||
sprintf( date, "%s", ctime(&now));
|
||||
date[strlen(date)-1] = 0;
|
||||
sprintf( str, "%s \"%s: %s s'est connecté le %s avec la commande: %s %s\"", commande, HOSTNAME, user, date, cmd, cmdline );
|
||||
id=fork();
|
||||
if(id>0)
|
||||
if ( start != 1 )
|
||||
{
|
||||
id=fork();
|
||||
if(id>0)
|
||||
{
|
||||
if ( (fh1 = fopen(logfile, "a")) == NULL)
|
||||
{
|
||||
perror(logfile);
|
||||
return 7;
|
||||
}
|
||||
fprintf(fh1, "%s: Connexion de %s\n#%s# %s\n", date, user, cmd, cmdline);
|
||||
fclose(fh1);
|
||||
}else if (id<0)
|
||||
{
|
||||
printf("erreur de création du fork: %s", str);
|
||||
}else
|
||||
{
|
||||
//printf("%s\n", str);
|
||||
r = system( str );
|
||||
exit (r);
|
||||
}
|
||||
}else
|
||||
{
|
||||
if ( (fh1 = fopen(logfile, "a")) == NULL)
|
||||
{
|
||||
@ -191,23 +211,7 @@ int main()
|
||||
if (start == 1)
|
||||
{
|
||||
fprintf(fh1, "%s: %s Connecté - %s %s", date, user, cmd, cmdline);
|
||||
}else
|
||||
{
|
||||
fprintf(fh1, "%s: Connexion de %s\n#%s# %s\n", date, user, cmd, cmdline);
|
||||
}
|
||||
fclose(fh1);
|
||||
}else if (id<0)
|
||||
{
|
||||
printf("erreur de création du fork: %s", str);
|
||||
}else
|
||||
{
|
||||
if (start != 1)
|
||||
{
|
||||
|
||||
//printf("%s\n", str);
|
||||
r = system( str );
|
||||
}
|
||||
exit (r);
|
||||
}
|
||||
}
|
||||
}else
|
||||
|
Reference in New Issue
Block a user