-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path19e.c
More file actions
40 lines (35 loc) · 996 Bytes
/
19e.c
File metadata and controls
40 lines (35 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
============================================================================
Name : 19e
Author : Piyush Singh
Description : Create a FIFO file by
a. mknod command
b. mkfifo command
c. use strace command to find out, which command (mknod or mkfifo) is better.
c. mknod system call
d. mkfifo library function
Date: 19th Sep, 2025.
============================================================================
*/
// Program: Create FIFO using mkfifo() library function
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
int main()
{
const char *fifo_name = "fifo_mkfifo";
// Create FIFO using mkfifo library function
if (mkfifo(fifo_name, 0666) == -1)
{
perror("❌ mkfifo failed");
exit(1);
}
printf("✅ FIFO created using mkfifo(): %s\n", fifo_name);
return 0;
}
/*
Output:
╰─ ./19e ─╯
✅ FIFO created using mkfifo(): fifo_mkfifo
*/