#include<apue.h>
#include<unistd.h>
#include<fcntl.h>
#include<string.h>
int main(int argc , char *argv[])
{
int fd = open("test.txt",O_WRONLY | O_CREAT | O_TRUNC);
int pid,status;
const char *str_for_parent = "str_for_parent\n";
const char *str_for_child = "str_for_child\n";
if ((pid = fork()) < 0)
err_sys("fork error");
else if (pid == 0)
{
write(fd,str_for_child,strlen(str_for_child)+1);
_exit(0);
}
wait(&status);
write(fd,str_for_parent,strlen(str_for_parent)+1);
return 0;
}
的test.txt
被打開()創建的。但它的權限(---------x
)是由touch
創建這些文件(-rw-rw-r--
),或在我的system.my任何其他軟件不同的umask是0002
爲什麼通過open()創建的文件的權限與touch不同?