ASR31-valarche-2021/Exemples/06-Tubes/ecrivain.c
2021-10-13 08:43:24 +02:00

22 lines
398 B
C

#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
int main (void) {
int fd;
char message[26];
sprintf(message, "bonjour du writer [%d]\n", getpid());
fd = open("my_tube", O_WRONLY);
printf("Ici writer [%d]\n", getpid());
if (fd != -1) {
write(fd, message, strlen(message));
}
else
printf("Désolé, je trouve pas le tube\n");
close(fd);
return 0;
}