关于daemonize()
来源:互联网 发布:mysql 自定义函数 编辑:程序博客网 时间:2024/06/05 04:42
lock_kernel();
siginitsetinv(¤t->blocked, SHUTDOWN_SIGS);
daemonize();
target_data.thread_id = current;
unlock_kernel();
注:SHUTDOWN_SIGS前面定义为# define SHUTDOWN_SIGS (sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGTERM)) target_data是前面定义的一个全局数据结构,thread_id是它的一个task_struct 结构的一个成员。这里的daemonize函数是什么作用?
siginitsetinv(¤t->blocked, SHUTDOWN_SIGS);
daemonize();
target_data.thread_id = current;
unlock_kernel();
注:SHUTDOWN_SIGS前面定义为# define SHUTDOWN_SIGS (sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGTERM)) target_data是前面定义的一个全局数据结构,thread_id是它的一个task_struct 结构的一个成员。这里的daemonize函数是什么作用?
1. linux-2.4.20\kernel\sched.c start from line 1283: 2. 3. /* 4. * Put all the gunge required to become a kernel thread without 5. * attached user resources in one place where it belongs. 6. */ 7. 8. void daemonize(void) 9. { 10. struct fs_struct *fs; 11. 12. 13. /* 14. * If we were started as result of loading a module, close all of the 15. * user space pages. We don't need them, and if we didn't close them 16. * they would be locked into memory. 17. */ 18. exit_mm(current); //因为是内核级daemon,所以不会再需要用户级的内存页面,释放之。这些页面是因为加载模块而申请到的。 19. 20. current->session = 1; 21. current->pgrp = 1; 22. current->tty = NULL;//因为是内核级daemon,所以不再需要终端控制台,所属会话为init会话,parent group为1(init),这样就成为init任务的一部分了。下面的代码则是释放文件系统相关资源,并且转为指向init任务的文件资源。 23. /* Become as one with the init task */ 24. 25. exit_fs(current); /* current->fs->count--; */ 26. fs = init_task.fs; 27. current->fs = fs; 28. atomic_inc(&fs->count); 29. exit_files(current); 30. current->files = init_task.files; 31. atomic_inc(*t->files->count); 32. }
- 关于daemonize()
- 关于daemonize()
- daemonize
- unix-daemonize()
- Python daemonize
- Redis daemonize介绍
- How to Daemonize in Linux
- How to Daemonize in Linux
- 'daemonize' is not a member of 'ACE'
- qemu中daemonize为什么要两次fork
- Linux守护进程运行命令daemonize
- carbon报错 Python Error - ImportError: cannot import name daemonize
- linux下rtl8188 驱动编译 出现类似 create_proc_entry daemonize 错误问题解决
- 关于
- 关于
- 关于++,--
- 关于#
- 关于。。。
- Spring 实现两种设计模式
- 补间动画基础备忘(1)
- linux 内核线程
- android 编译libjpeg
- 解决windows连接不上solaris上的ftp服务问题
- 关于daemonize()
- jQuery知识总结
- ubuntu 恢复bash的自动补全
- javascript小技巧总结
- 软件开发思考
- android 两张图片合并作背景图
- Eclipse重构——Separate Query from Modify
- VC编程中经常能遇到LNK2005错误解决办法
- 今天的氧气的制造厂企业即时通讯