ASR31-valarche-2021/Exemples/04-Exec/avantExec.c
2021-09-29 11:31:40 +02:00

23 lines
639 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
char tabRef[1000];
main() {
printf("Caractéristiques avant recouvrement\n");
printf(" Identité du processus : %d\n", getpid());
printf(" Identité du processus père:%d\n",getppid());
printf(" Propriétaire réel : %d\n", getuid());
printf(" Propriétaire effectif : %d\n", geteuid());
printf(" Répertoire de travail:%s\n",getcwd(tabRef,1000));
/* demande de fermeture automatique de lentrée standard au recouvrement */
fcntl(STDIN_FILENO, F_SETFD, fcntl(STDIN_FILENO,F_GETFD,0)|FD_CLOEXEC);
execl("apresExec", "apresExec", NULL);
perror("execl");
}