#include <unistd.h>
#include<stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
int main (int argc, char * argv[])
{
int enteroParaElPipe;
int IDPROGRAMACLIENTE=getpid();
printf("%d",IDPROGRAMACLIENTE);
if((mkfifo("pipe",0666))==-1)
{
perror("error creating pipe, type 1");
exit(1);
}
if((enteroParaElPipe=open("pipe",O_WRONLY))==-1)
{
perror("error creating pipe, type 2");
exit(1);
}
char comando[200];
if(scanf("%199s", comando) == 1)
puts(comando);
int written;
escritos=write(enteroParaElPipe,"HOLA\n",5);
printf("Written: %d\n",written);
close(enteroParaElPipe);
return 0;
}
При попытке запустить этот код я получаю:
error creating pipe: Invalid argument
Почему?
(Изменения основаны на первых добавленных ответах)