当前位置: 技术问答>linux和unix
一个c 程序的疑惑?????
来源: 互联网 发布时间:2016-05-19
本文导语: include #include #include #include #include #define TRUE 1 #define STACK_SIZE 128 int p1() { while(TRUE) { printf("I am process %dn",getpid()); sleep(2); } } int main() { pid_t pid char *stack; stack=(char*)malloc(STACK_SIZE); if(!stack) { perror("mall...
include
#include
#include
#include
#include
#define TRUE 1
#define STACK_SIZE 128
int p1()
{
while(TRUE)
{
printf("I am process %dn",getpid());
sleep(2);
}
}
int main()
{
pid_t pid
char *stack;
stack=(char*)malloc(STACK_SIZE);
if(!stack)
{
perror("malloc source");
exit(EXIT_FAILURE);
}
if((pid=clone(&p1,stack+STACK_SIZE-1, SIGCHLD|CLONE_FS | CLONE_FILES ,0))
#include
#include
#include
#include
#define TRUE 1
#define STACK_SIZE 128
int p1()
{
while(TRUE)
{
printf("I am process %dn",getpid());
sleep(2);
}
}
int main()
{
pid_t pid
char *stack;
stack=(char*)malloc(STACK_SIZE);
if(!stack)
{
perror("malloc source");
exit(EXIT_FAILURE);
}
if((pid=clone(&p1,stack+STACK_SIZE-1, SIGCHLD|CLONE_FS | CLONE_FILES ,0))