#include<stdio.h>#include<unistd.h>#include<stdlib.h>#include<signal.h>
void myhandler(int sig)
{printf("my sig is %d\n",sig);
}
int main()
{pid_t id = fork();signal(SIGCHLD,myhandler);if(id == 0)//child{printf("i am child!pid:%d\n",getpid());sleep(5);exit(1);}else //father{while(id = waitpid(id,NULL,0) > 0){printf("wait child success:%d pid:%d\n",id,getpid());}printf("child is quit!%d\n",getpid());}return0;
}
文件内容
[koulocalhost makefile]$ cat 1.c
#include "3.h"
int main()
{key_t key ftok(".",1);printf("%d\n",add(1,2));return 0;
}[koulocalhost makefile]$ cat 2.c
#include "3.h"
int add(int a, int b)
{return a b;
}
[k…
先看 普通菱形继承
#include <iostream>
#include <string>
using namespace std;
class Animal {int a_age;
};
class Sheep : public Animal {};
class Tuo : public Animal {};
class SheepTuo : public Sheep, public Tuo {};
void test1() {cout << …