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++查出来,不好意思,我是新手。还望指教。谢
分值 ......
最近在看一个用bison实现的C parser,OS是opensolaris。当用它来解析一个简单的hello.c时,出现“/usr/include/sys/va_list.h: parse error before __gnuc_va_list”。打开文件va_list.h后发现这样一行“typedef __bu ......
写了个测试程序如下
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......
有个winform程序,使用c#+mysql,需要在一个窗体设置mysql自动删除功能,包括自动删除多少天之前的数据以及是否开启自动删除功能,我程序退出后,还怎么控制Mysql自己删除啊?是不是要用mysql的event来实现?c#可以调用mysq ......
#include "stdio.h"
int main()
{
char *ch(char *, char *);
char str1[]="I am glad to meet you!";
char str2[]="Welcom to study C!";
&nb ......