使用daemon函数的问题。

yrj 2002-11-05 10:43:28
代码如下
main()
{
printf("yrj1\n");
daemon();
sleep(10);
printf("yrj2\n");
}
编译正常,可以运行到daemon,程序到后台执行,但是 两个输出最后一起出来,并没有在输出"yrj1"后在出现命令提示符,为什么?用其他方法怎么实现。
...全文
203 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
yrj 2002-11-08
  • 打赏
  • 举报
回复
谢谢,不过效果不算太好,输出一个“yrj2”后,不能立刻进入提示符下,要按回车才能。为什么?
blh 2002-11-07
  • 打赏
  • 举报
回复
看/usr/share/man/man2和/usr/share/man/man3中的文件就是函数说明文档
yrj 2002-11-07
  • 打赏
  • 举报
回复
GNU网站上的glibc库,没有这个函数的说明
walkonthesky 2002-11-07
  • 打赏
  • 举报
回复
有这个函数
知道了
yrj 2002-11-06
  • 打赏
  • 举报
回复
up
blh 2002-11-06
  • 打赏
  • 举报
回复
你的系统是什么???我的是linux,没有你那样的调用
#include <unistd.h>

int daemon(int nochdir, int noclose);

DESCRIPTION
The daemon() function is for programs wishing to detach themselves from the con-
trolling terminal and run in the background as system daemons.

Unless the argument nochdir is non-zero, daemon() changes the current working
directory to the root ("/").

Unless the argument noclose is non-zero, daemon() will redirect standard input,
standard output and standard error to /dev/null.
yrj 2002-11-06
  • 打赏
  • 举报
回复
请问您有LINUX下GCC的c库吗?那个GNU上的glib库,不利于索引,谢谢
yrj1978@21cn.com

23,121

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧