LinuxÒÁµéÔ°ÂÛ̳'s Archiver

akun77 ·¢±íÓÚ 2002-12-26 16:12

½ø³Ì¹ÜÀíµÄÒ»¸öСÎÊÌâ

ÎÒʹÓõÄÊÇredhat8.0,ÔÚÒ»±¾ÊéÉÏÓиö¼òµ¥µÄ¹ØÓÚ½ø³Ì¹ÜÀíµÄÀý×Ó,µ«ÊÇÎÒÓÃgcc±àÒëÊÇÈ´²»ÕýÈ·,Ï£Íû´óϺ°ïæ½â´ðÒ»ÏÂ
#include<unistd.h>
#include<stdio.h>
char string1[]="Hello";
char string2[]="World.";
int main(void)
{
pid_t PID;
PID=fork();
if(PID==-1)
{
perror("fork error ");
exit(1);
}
if(PID==0)
printf("%s",string1);
else
printf("%s",string2);
exit(0);
}
ÔÚ±àÒëµÄÊä³öÀïÃæÖ¸³ö²»ÈÏʶ"pid_t"
ÇëÎÊÕâ¸öÊÇʲô±êÖ¾,»¹ÓÐunistd.hÊÇÒ»¸ö¹ØÓÚʲôµÄÍ·º¯Êý.

faraway ·¢±íÓÚ 2002-12-27 15:36

#include <stdlib.h>

pid_t is a process identification,it's defined as:
typedef int __pid_t
typedef __pid_t pid_t

unistd.h includes all the system call functions

Ò³: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.