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

高级Linux程序设计第三章:进程

每个进程都有一个唯一的进程号。 每个进程都有一个父进程。 系统中的进程以树的形式组织,init进程(进程号为1)作为根。 进程0是调度进程,没有程序与之对应,是内核的一部分。 进程1是init进程,是在系统启动的阶段由内核启动的,对应/sbin/init程序,是普通的用户进程。 程序中可以通过getpid()得到进程号,通过getppid()得到父进程的进程号。 #include #include int main () {     printf (“The process ID is %d\n”, (int) getpid ());     printf (“The parent process ID is %d\n”, (int) getppid ());     return 0; } 通过ps命令可以得到系统中运行的所有进程。 通过kill命令可以杀掉某个进程。 1、创建进程 1.1、system函数 system函数提供了一种在程序中运行一个命令的简单方法。 #include int main () {     int return_value;     return_value = system (“ls -l /”);     return return_value; } 1.2、fork及exec函数 当程序调用fork的时候,则一个完全复制的子程序被创建。 父进程将从fork被调用的地方继续执行下去。 子进程也是从相同的地方运行下去。 父进程中fork函数的返回值是子进程的进程号。 子进程中fork函数的返回值是零。 #include #include #include int main () {     pid_t child_pid;     printf (“the main program process ID is %d\n”, (int) getpid ());     child_pid = fork ();     if (child_pid != 0) {         printf (“this is the parent process, with id %d\n”, (int) getpid ());     


相关文档:

Linux 汇编语言开发指南


developerWorks 中国
  >  
Linux
  >
Linux 汇编语言开发指南
文档选项
<tr
valign="top"><td width="8"><img alt="" height="1" width="8"
src="//www.ibm.com/i/c.gif"/></td>< ......

linux init六种模式简介


init是Linux系统里的根进程,是系统所有进程的祖先。它的主要作用是根据记录在/etc/inittab里的一个脚本(script)程序产生进程。这个文件通常用于控制用户的登录模式。Linux系统的有效登录模式有0~9共十种,不过沿用UNIX系统的至多6种的限制,一般只有1到6有效。
  init一般在系统启动时自动运行,也可以由root用户调 ......

Linux下利用条件变量实现读写锁

首先介绍下pthread_cond_t。 在Linux下称之为状态变量,与之相关的有下面几个API:
    int pthread_cond_init (pthread_cond_t *COND,pthread_condattr_t *cond_ATTR);
    int pthread_cond_signal (pthread_cond_t *COND);
    int pthread_cond_broadcast (pthread_con ......

实战Linux Bluetooth编程

文章来源:http://blog.chinaunix.net/u3/104073/showart_2081838.html
实战Linux Bluetooth编程(一) 协议栈概述
Sam一年前在Linux下写了一个类似Windows下BTW的库--BTX。现在需要添加新功能时发现很多知识点都忘记
了。所以决定在这次学习中,把一些bluez API记录下来。这几天又想,这样还不够,不如把Linux下的
Blu ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号