25 lines
435 B
C
25 lines
435 B
C
#define _GNU_SOURCE
|
|
#include <fcntl.h>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <unistd.h>
|
|
#include <assert.h>
|
|
|
|
// ls -i -l /tmp >> log
|
|
//
|
|
int main(int argc, char *argv[])
|
|
{
|
|
|
|
|
|
int redirection = open("./log",O_WRONLY | O_APPEND | O_CREAT , 0644);
|
|
|
|
assert(redirection >= 0);
|
|
// dup2 ferme 1, et duplique redirection
|
|
dup2(redirection,1);
|
|
close(redirection);
|
|
|
|
execlp("ls","ls","-i","-l","/tmp",NULL);
|
|
assert(0);
|
|
return 0;
|
|
}
|