关于daemonize()
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函数是什么作用?
linux-2.4.20\kernel\sched.c start from line 1283:/*
* Put all the gunge required to become a kernel thread without
* attached user resources in one place where it belongs.
*/void daemonize(void)
{struct fs_struct *fs;/** If we were started as result of loading a module, close all of the* user space pages. We don't need them, and if we didn't close them* they would be locked into memory.*/exit_mm(current); //因为是内核级daemon,所以不会再需要用户级的内存页面,释放之。这些页面是因为加载模块而申请到的。current->session = 1;current->pgrp = 1;current->tty = NULL;//因为是内核级daemon,所以不再需要终端控制台,所属会话为init会话,parent group为1(init),这样就成为init任务的一部分了。下面的代码则是释放文件系统相关资源,并且转为指向init任务的文件资源。/* Become as one with the init task */exit_fs(current); /* current->fs->count--; */fs = init_task.fs;current->fs = fs;atomic_inc(&fs->count);exit_files(current);current->files = init_task.files;atomic_inc(*t->files->count);
}
关于daemonize()相关推荐
- linux中daemonize用法,daemonize Unix系统后台守护进程管理软件
在我们的工作中,很多时候都需要在linux中后台运行程序, 方法1: nohup & 方法2: daemonize Unix系统后台守护进程管理软件 优点:更加正规 后台运⾏更稳定 git c ...
- 在linux将一些程序放到后台运行的方法(nohup/screen/daemonize)
方法一:nohup # nohup sh xkahn.sh & 方法二:screen 1.先安装screen程序 yum install -y screen 2.运行screen程序 (注释: ...
- redis的daemonize设置为yes和no有啥区别呀,为啥我两个都试了之后的效果不是像网上说的那样,设置成No的话,redis也会一直运行呀
redis的daemonize设置为yes和no有啥区别呀,为啥我两个都试了之后的效果不是像网上说的那样,设置成No的话,redis也会一直运行呀
- How to Daemonize in Linux
转自http://www.itp.uzh.ch/~dpotter/howto/daemonize 简单易懂的daemonize实现代码: #include <stdio.h> #inclu ...
- undefined local variable or method `daemonize‘ for puma
puma 5.x后出现的问题 Gemfile添加 gem 'puma-daemon', require: false gem 'puma' config/puma.rb添加 require 'puma ...
- linux daemonize 命令,Linux守护进程运行命令daemonize
我们一般在编写服务器的时候都希望能让服务器在后台运行,而且能记录下这个服务器的pid,防止一个进程重复启动.之前我的方案是自己使用fork函数,将服务器运行成后台模式:并且在启动之前去检查配置文件中指 ...
- Redis daemonize介绍
欢迎访问我的个人博客网站:http://www.yanmin99.com/ Redis daemonize介绍 一.Redis daemonize介绍 1.daemonize介绍 A.redis.co ...
- Linux守护进程运行命令daemonize
我们一般在编写服务器的时候都希望能让服务器在后台运行,而且能记录下这个服务器的pid,防止一个进程重复启动.之前我的方案是自己使用fork函数,将服务器运行成后台模式:并且在启动之前去检查配置文件中指 ...
- 你知道在Redis中daemonize的yes和no有什么区别吗?
daemonize是用来指定redis是否要用守护线程的方式启动. 当我们采用yes时,redis会在后台运行,此时redis将一直运行,除非手动kill该进程.同时将进程pid号写入至redis.c ...
最新文章
- gulp关于scss的基础配置
- GitHub 4.6 万星:Windows Terminal 预览版开放下载!
- 原生JS写Ajax的请求函数
- mongodb在aggregate lookup 进行分页查询,获得记录总数
- domino缺省注册服务器或无法访问,Domino服务器挂起时的现象
- Win7系统隐藏文件恢复的方法
- dubbo负载均衡策略配置
- 5-9轻量型网络结构
- QT QComboBox使用总结
- CS224n研究热点11 深度强化学习用于对话生成
- android应用安全——数据安全
- 《C++(一)--类》
- Burp Suite使用介绍说明
- 布隆(Bloom Filter)过滤器——全面讲解,建议收藏
- C语言程序设计精髓习题总汇
- msbuild ConfuserEx.Build 加密
- 分享三款免VIP软件,小众实用,正是你需要但没找到的
- 推荐8个私藏多年的实用软件,你一定用得到!
- STM32Cube的PWM控制基础篇(一)一路PWM设置
- 使用python获取IP地址