如果你讀手冊頁,你就會知道O_CREAT
是一個無效的參數mkfifo()
:
mkfifo()生成一個名爲pathname的FIFO特殊文件mode指定FIFO的權限,它由進程的umask以通常的方式修改:創建的文件是(模式&〜umask)。
的權限位標誌在<sys/stat.h>
定義,可以在你的系統通過讀取聯機幫助頁stat(2)
進行協商。以下是有關名單:
S_IRUSR 00400 owner has read permission
S_IWUSR 00200 owner has write permission
S_IXUSR 00100 owner has execute permission
S_IRGRP 00040 group has read permission
S_IWGRP 00020 group has write permission
S_IXGRP 00010 group has execute permission
S_IROTH 00004 others have read permission
S_IWOTH 00002 others have write permission
S_IXOTH 00001 others have execute permission
所以,你的問題是通過傳遞正確的許可標誌,以mkfifo()
解決。假設你想要rw-rw-rw
,那麼你應該這樣做:
mkfifo("signal", S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);