1
0

debug fork

This commit is contained in:
Daniel Tartavel 2020-05-05 10:29:16 +02:00
parent 82c0754829
commit 8516ab5089

36
main.c
View File

@ -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 );
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