LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 779|回复: 1

问个关于apue的问题

[复制链接]
发表于 2006-1-15 10:20:39 | 显示全部楼层 |阅读模式
刚刚开始看Advanced Programming in UNIX Environment, 里面Chapter 1练习题的1.2题:
In the output from the program in Figure 1.6, what happened to the processes with process IDs 852 and 853?
是这样的,它是一个这样的程序:

  1. #include "apue.h"
  2. int
  3. main(void)
  4. {
  5.     printf("hello world from process ID %d\n", getpid());
  6.     exit(0);
  7. }
复制代码

调用如下:

  1. $ ./a.out
  2. hello world from process ID 851
  3. $ ./a.out
  4. hello world from process ID 854
复制代码

请问是怎么回事呢?
我的Debian Linux,我试调用了一下程序,我的两个pid输出是连续的呀。
发表于 2006-1-15 11:16:44 | 显示全部楼层
正常的,进程号应该不会连续的
在你两次很连续的执行同一个程序产生pid的之间的间隔基本应该还有其他后台进程产生吧。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表