Chinaunix首页 | 论坛 | 博客
  • 博客访问: 968660
  • 博文数量: 200
  • 博客积分: 5011
  • 博客等级: 大校
  • 技术积分: 2479
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-27 15:07
文章分类

全部博文(200)

文章存档

2009年(12)

2008年(190)

我的朋友

分类:

2008-12-25 19:09:33

Chapter 13 exercises

As we might guess from , when the syslog facility is initialized, either by calling openlog directly or on the first call to syslog, the special device file for the UNIX domain datagram socket, /dev/log, has to be opened. What happens if the user process (the daemon) calls chroot before calling openlog?

答案: 就不能正确打开那个文件了,建议使用LOG_NDELAY

call openlog with an option of LOG_NDELAY, before calling chroot

Write a program that calls the daemonize function in . After calling this function, call getlogin () to see whether the process has a login name now that it has become a daemon. Print the results to a file.

答案:成为daemon之后,没有了controlling terminnal,这样getlogin就不能依据conrolling terminal去查看utmp文件从而找到login name了。当然有的实现可能不是这样的。在linuxsolaris就查不出来,但是在Free BSDMac中,login name被记录在了process table entry中。因此还是可以不通过controlling terminal来查到login name的。

阅读(1051) | 评论(0) | 转发(0) |
0

上一篇:13.6 daemon conventions

下一篇:猜生日

给主人留下些什么吧!~~