mkfifo 명령을 사용하여 Linux에서 c로 명명 된 파이프를 만들려고합니다. 나는 아직도 배우고mkfifo를 실행하는 프로그램이 작동하지 않습니다.
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#define MAX_LINE 80
int main(int argc, char** argv) {
int create;
//mkfifo("/tmp/myfifo", 0666);
create = mkfifo("tmp/myfifo", 0666);
if (create==-1)
{
printf("error%s", strerror(errno));
}
char line[MAX_LINE];
int pipe;
pipe = open("/tmp/myfifo", O_WRONLY);
if (pipe==-1)
{printf("error");
}
printf("Enter line: ");
fgets(line, MAX_LINE, stdin);
write(pipe, line, strlen(line));
sleep (100);
close(pipe);
return 0;
}
: 나는이 프로그램을 실행할 때, 나는 중 하나는 여기에
내 코드입니다 (콘솔 아무것도 표시되지 않습니다)는 "그런 파일 또는 디렉터리"오류 또는 절대적으로 아무것도 얻을 , 나는 내가 뭘 잘못하고 있는지 이해하지 못한다. 당신의 도움을 주셔서 감사합니다.
[ask]를 보시고, 조언과 형식을 따라하고이 엉망을 정확하게 들여 쓰십시오. – Olaf