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

Linux 下C问题

进程创建函数fork与vfork

C/C++ code:

#include<stdio.h>
#include<sys/types.h>
#include<unistd.h>
int globflag=9;
main()
{
pid_t pid;
int flag=0;
int i=0;

printf("vfork is diffirent with vfork\n");

// pid=fork();
pid=vfork();
if(pid==0)
{
i=3;
while(i-- >0)
{
printf("child process is running\n");
globflag++;
flag++;
sleep(1);
}
printf("child process:globflag=%d,flag=%d\n",globflag,flag);
}
else if(pid>0)
{
i=5;
while(i-- >0)
{
printf("parents process is running\n");
globflag++;
flag++;
sleep(1);
}
printf("parents process:globflag=%d,flag=%d\n",globflag,flag);
}
else
printf("process creat fail\n");
}



运行结果:
vfork is diffirent with vfork
child process is running
child process is running
child process is running
child process:globflag=12,flag=3
parents process is running
parents process is running
parents process is running
parents process is running
parents process is running
parents process:globflag=


相关问答:

如何查找系统未安装补丁C - C/C++ / 新手乐园

请问各位高手如何用C/C++获得系统未安装补丁
好像很专业的东西。。。

查注册表
每个补丁如果安装了都会在注册表里面登记

请问能不能更清晰些,我想用c\c++查出来,不好意思,我是新手。还望指教。谢

分值 ......

问两道 C 面试题,高手帮看一下

1. 如下定义会有什么错误发生
  //file1.c
  int a[10];
  //file2.c
  extern int *a;
2. 大容量全局变量有什么危害,如
   
  //file.c
  ......

<c:forEach 输出Set集合的问题

<table width="100%" border="1" cellpadding="0" cellspacing="0">
  <c:forEach items="${quaeres}" var="q"> 
......

C 程序问题(四) - C/C++ / C语言

#include "stdio.h"
int main()
{
  char *ch(char *, char *);
  char str1[]="I am glad to meet you!";
  char str2[]="Welcom to study C!";
&nb ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号