易截截图软件、单文件、免安装、纯绿色、仅160KB

linux内核读书笔记(进程终止函数分析)三

do_exit() Function
-----------------------------------------------------------------------
kernel/exit.c
707 NORET_TYPE void do_exit(long code)
708 {
709 struct task_struct *tsk = current;
710
711 if (unlikely(in_interrupt()))
712 panic("Aiee, killing interrupt handler!");
713 if (unlikely(!tsk->pid))
714 panic("Attempted to kill the idle task!");
715 if (unlikely(tsk->pid == 1))
716 panic("Attempted to kill init!");
717 if (tsk->io_context)
718 exit_io_context();
719 tsk->flags |= PF_EXITING;
720 del_timer_sync(&tsk->real_timer);
721
722 if (unlikely(in_atomic()))
723 printk(KERN_INFO "note: %s[%d] exited with preempt_count %d\n",
724 current->comm, current->pid,
725 preempt_count());
-----------------------------------------------------------------------
Line 707参数code是进城返回给父进程的退出码 Lines 711716 确保目前进程不是一个中断处理进程,确保不是idle进程(PID=0)或者是init进程(PID=1),init进程只有系统被终止时才能退出; Line 719 将该进程的flags域设置为PF_EXITING,这表明当前进程被终止; -----------------------------------------------------------------------
kernel/exit.c
...
727 profile_exit_task(tsk);
728
729 if (unlikely(current->ptrace & PT_TRACE_EXIT)) {
730 current->ptrace_message = code;
731 ptrace_notify((PTRACE_EVENT_EXIT << 8) | SIGTRAP);
732 }
733
734 acct_process(code);
735 __exit_mm(tsk);
736
737 exit_sem(tsk);
738 __exit_files(tsk);
739 __exit_fs(tsk);
740 exit_namespace(tsk);
741 exit_thread();
...
-----------------------------------------------------------------------
Lines 729732 如果进程被ptraced而且PT_TRACE_EXIT 被设置,我们将exit_code作为消息通知父进程 Lines 735742 将进程中不用的资源clean up掉,__exit_mm()用于释放分配给进程的内存,和释放和此进程相关的mm_struct,exit_sem()将此任务从IPC中分离,__exit_files() 释放分配给任务的文件,并且将其标识符减去,_


相关文档:

Linux iptable文档

总览
用iptables -ADC 来指定链的规

,-A添加 -D删除 -C 修改
iptables - [RI] chain rule num rule-specification[option]
用iptables - RI 通过规则的顺序指定
iptables -D chain rule num[option]
删除指定规则
iptables -[LFZ] [chain][option]
用iptables -LFZ 链名 [选项]
iptables -[NX] chain
用 -NX ......

GNU/Linux 开发环境 (2)


继续谈谈其它语言的开发。
3.2) 动态语言
这里指的是包括脚本语言,解释型语言在内的编程语言,例如Java,Perl,Python,PHP,JavaScript,Ruby,Shell Script,等等。
从开发环境角度看,动态语言都有自己的运行环境,而且通常都是跨平台的。因此,编写代码,调试运行则完全可以在自己的环境中完成,只是大多是命令行 ......

linux内核读书笔记(进程数据结构分析)一

include/linux/sched.h
384   struct task_struct {
385     volatile long state;
386     struct thread_info *thread_info;
387     atomic_t usage;
388     unsigned long flags; 
389   &nbs ......

Linux常用名令 1文件操作命令

1. ls:列出文件列表
       格式: ls  option,option可以是: -a 列出隐藏文件,-l 列出文件详细信息
2. pwd:查看当前目录
3. mkdir: 创建目录
4. touch: 创建文件
5. cd: 切换目录
6. cp: 拷贝文件/目录
      格式: cp  srcfile desfi ......

安装 Suse 10.3 及 Linux 笔记

This is a memo of setting up Suse 10.3 on Mon Mar 17, 5:18 PM
Download Open Suse: http://en.opensuse.org and see http://en.opensuse.org/Download_Help
Summary - These tools were configured to use:
Apache 2.2 web server
Bison 2.3
Flex 2.5.33
Ftp server
Gcc 4.2.1 (C/C++)
Java 1.5.0
Mon ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号