LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 561|回复: 2

应用程序中能否使用函数set_close_on_exec(...)?

[复制链接]
发表于 2005-3-18 11:33:31 | 显示全部楼层 |阅读模式
我的程序中要用fork+exec启动一些其他子程序,但是我不希望子进程继承父进程所打开的文件,我发现set_close_on_exec(...)可以满足我的需要。但是使用的时候发现编译出错,如下:

In file included from

/include/linux/file.h: In function `int get_close_on_exec(unsigned int)':

Error : `current' undeclared (first use this function)
file.h line 13

Error : (Each undeclared identifier is reported only once
file.h line 13

是不是file.h是给kernel使用的,我能用什么API达到我的需要呢?
发表于 2005-3-18 16:41:03 | 显示全部楼层
fcntl(fd, FD_SETFD, FD_CLOEXEC)打开close on exec
fcntl(fd, FD_SETFD, 0)关闭 close on exec
查看 <<APUE>> p64
回复 支持 反对

使用道具 举报

发表于 2005-3-18 18:39:35 | 显示全部楼层
看样子,好像是少包含了什么头文件 。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表