欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

[Linux進(jìn)程]一個(gè)完整的進(jìn)程操作實(shí)例

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/wait.h>
#include <string.h>
#include <error.h>
char command[256]; 
void main() 
{ 
  int rtn; /*子進(jìn)程的返回?cái)?shù)值*/ 
  while(1) 
  { 
    printf( ">" );              //從終端讀取要執(zhí)行的命令 
    fgets(command, 256, stdin); //將命令數(shù)據(jù)存放到command中
    command[strlen(command)-1] = 0; 
    if (fork() == 0 )          //在子進(jìn)程中執(zhí)行這個(gè)命令
    {  
      execlp(command,command,NULL); 
      //如果exec函數(shù)返回,表明沒有正常執(zhí)行命令,打印錯(cuò)誤信息
      perror(command); 
      exit(1); 
    } 
    else  //在父進(jìn)程中等待字進(jìn)程結(jié)束,并且打印子進(jìn)程的返回值
    { 
      wait( &rtn ); 
      printf("子進(jìn)程返回%d\n",rtn); 
      exit(0);
    } 
  } 
  exit(0);
}

當(dāng)前文章:[Linux進(jìn)程]一個(gè)完整的進(jìn)程操作實(shí)例
文章地址:http://chinadenli.net/article16/gsphdg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣網(wǎng)頁設(shè)計(jì)公司服務(wù)器托管云服務(wù)器網(wǎng)站維護(hù)網(wǎng)站設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

商城網(wǎng)站建設(shè)