Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <unistd.h>
- #include <sys/wait.h>
- int main(int argc, char *argv[]) {
- pid_t pid;
- int fd[2];
- char buffer[4096];
- errno = 0;
- if (argc < 2) {
- printf("Usage ./log command \n");
- return;
- }
- printf("[LOG] Début du programme pid : %d \n", getpid());
- int err = pipe(fd);
- if (err == -1) {
- printf("Erreur lors de la création du pipe\n");
- return -1;
- }
- pid = fork();
- if (pid == 0) {
- dup2(fd[1], STDOUT_FILENO);
- close(fd[0]);
- close(fd[1]);
- int err = execlp(argv[1], argv[1], (char *) 0);
- if (err == -1) {
- printf("Erreur execlp argv[1] \n");
- return -1;
- }
- }
- else if (pid > 0) {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement