Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

linux waitº¯Êý½âÎö

½ø³ÌÒ»µ©µ÷ÓÃÁËwait£¬¾ÍÁ¢¼´×èÈû×Ô¼º£¬ÓÉwait×Ô¶¯·ÖÎöÊÇ·ñµ±Ç°½ø³ÌµÄij¸ö×Ó½ø³ÌÒѾ­Í˳ö£¬Èç¹ûÈÃËüÕÒµ½ÁËÕâÑùÒ»¸öÒѾ­±ä³É½©Ê¬µÄ×Ó½ø³Ì£¬wait ¾Í»áÊÕ¼¯Õâ¸ö×Ó½ø³ÌµÄÐÅÏ¢£¬ ²¢°ÑËü³¹µ×Ïú»Ùºó·µ»Ø£»Èç¹ûûÓÐÕÒµ½ÕâÑùÒ»¸ö×Ó½ø³Ì£¬wait¾Í»áÒ»Ö±×èÈûÔÚÕâÀֱµ½ÓÐÒ»¸ö³öÏÖΪֹ¡£
wait£¨µÈ´ý×Ó½ø³ÌÖжϻò½áÊø£©
Ïà¹Øº¯Êý waitpid£¬fork
±íÍ·Îļþ
#include<sys/types.h>
#include<sys/wait.h>
¶¨Ò庯Êý pid_t wait (int * status);
º¯Êý˵Ã÷
wait£¨£©»áÔÝʱֹͣĿǰ½ø³ÌµÄÖ´ÐУ¬Ö±µ½ÓÐÐźÅÀ´µ½»ò×Ó½ø³Ì½á
Êø¡£Èç¹ûÔÚµ÷ÓÃwait£¨£©Ê±×Ó½ø³ÌÒѾ­½áÊø£¬Ôòwait£¨£©»áÁ¢¼´·µ
»Ø×Ó½ø³Ì½áÊø״ֵ̬¡£×Ó½ø³ÌµÄ½áÊø״ֵ̬»áÓɲÎÊýstatus ·µ»Ø£¬
¶ø×Ó½ø³ÌµÄ½ø³Ìʶ±ðÂëÒ²»áÒ»¿ì·µ»Ø¡£Èç¹û²»ÔÚÒâ½áÊø״ֵ̬£¬Ôò
²ÎÊýstatus ¿ÉÒÔÉè³ÉNULL¡£×Ó½ø³ÌµÄ½áÊø״ֵ̬Çë²Î¿¼waitpid£¨£©¡£
·µ»ØÖµ
Èç¹ûÖ´Ðгɹ¦Ôò·µ»Ø×Ó½ø³Ìʶ±ðÂ루PID£©£¬Èç¹ûÓдíÎó·¢ÉúÔò·µ»Ø
-1¡£Ê§°ÜÔ­Òò´æÓÚerrno ÖС£
¸½¼Ó˵Ã÷
·¶Àý Ò»
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/wait.h>
int main()
{
pid_t pid;
int status,i;
if(fork()= =0){
printf(“This is the child process .pid =%d\n”,getpid());
exit(5);
}else{
sleep(1);
printf(“This is the parent process ,wait for child...\n”;
pid=wait(&status);
i=WEXITSTATUS(status);
printf(“child’s pid =%d .exit status=%d\n”,pid,i);
}
}
Ö´ÐÐ
This is the child process.pid=1501
This is the parent process .wait for child...
child’s pid =1501,exit status =5
·¶Àý ¶þ
#include<iostream>
#include<unistd.h>
#include<sys/wait.h>
using namespace std;
int main(void)
{
        pid_t pid;
        pid =fork();
        if (pid<0)
                exit(0);
        else if (pid == 0)
        {
         


Ïà¹ØÎĵµ£º

Linux Íø¿¨ÅäÖÃÎļþ¼°Ïà¹ØÉèÖÃ


1.ÅäÖÃÎļþ
/etc/hosts(±¾µØÖ÷»úipµØÖ·Ó³Éä,¿ÉÒÔÓжà¸ö±ðÃû£©¡£
/etc/services(¶Ë¿ÚºÅÓë±ê×¼·þÎñÖ®¼äµÄ¶ÔÓ¦¹Øϵ£©¡£
/etc/sysconfig/network£¨ÉèÖÃÖ÷»úÃû£¬Íø¹Ø£¬ÓòÃû£©¡£
HOSTANME=zjw.com(Ö÷»úÃû£©£¨ÐèÒªÖØÆô¼ÆËã»ú²ÅÓÐЧ£©
GATEWAY=192.168.1.1£¨Íø¹Ø£©
/etc/rc.d/init.d/network restart£¨½Å±¾·þÎñÆô¶¯)
servi ......

ÉîÈë·ÖÎö Linux ÄÚºËÁ´±í


ÉîÈë·ÖÎö Linux ÄÚºËÁ´±í
 
 
¼¶±ð£º ³õ¼¶
ÑîɳÖÞ (pubb@163.net)¹ú·À¿Æ¼¼´óѧ¼ÆËã»úѧԺ
2004 Äê 8 ÔÂ 01 ÈÕ
±¾ÎÄÏêϸ·ÖÎöÁË 2.6.x ÄÚºËÖÐÁ´±í½á¹¹µÄʵÏÖ£¬²¢Í¨¹ýʵÀý¶Ôÿ¸öÁ´±í²Ù×÷½Ó¿Ú½øÐÐÁËÏ꾡µÄ½²½â¡£
Ò»¡¢ Á´±íÊý¾Ý½á¹¹¼ò½é
Á´±íÊÇÒ»ÖÖ³£ÓõÄ×éÖ¯ÓÐÐòÊý¾ÝµÄÊý¾Ý½á¹¹£¬Ëüͨ¹ýÖ¸Õ뽫һϵÁÐÊý¾Ý½Úµ ......

LinuxϵͳϵĶàÏ̱߳à³ÌÈëÃÅËÄ

3¡¢Ìõ¼þ±äÁ¿ 
¡¡¡¡Ç°Ò»½ÚÖÐÎÒÃǽ²ÊöÁËÈçºÎʹÓû¥³âËøÀ´ÊµÏÖÏ̼߳äÊý¾ÝµÄ¹²ÏíºÍͨÐÅ£¬»¥³âËøÒ»¸öÃ÷ÏÔµÄȱµãÊÇËüÖ»ÓÐÁ½ÖÖ״̬£ºËø¶¨ºÍ·ÇËø¶¨¡£¶øÌõ¼þ±äÁ¿Í¨¹ýÔÊÐíÏß³Ì×èÈûºÍµÈ´ýÁíÒ»¸öÏ̷߳¢ËÍÐźŵķ½·¨ÃÖ²¹ÁË»¥³âËøµÄ²»×㣬Ëü³£ºÍ»¥³âËøÒ»ÆðʹÓá£Ê¹ÓÃʱ£¬Ìõ¼þ±äÁ¿±»ÓÃÀ´×èÈûÒ»¸öỊ̈߳¬µ±Ìõ¼þ²»Âú×ãʱ£¬Ïß³ÌÍùÍù½â¿ªÏ ......

Linux¸ùÎļþϵͳ½á¹¹ÔÙÈÏʶ


INTRO
¾¡¹ÜLinuxµÄ¸ùÎļþϵͳÔÚÐÎʽ±íÏÖÉÏÊÇÒ»ÌåµÄ£¨ËùÓÐÊý¾ÝĿ¼¾ùΪ¸ùĿ¼ÏµÄ×ÓĿ¼£©£¬µ«Êµ¼ÊËüÃÇÊǶà¸ö²»Í¬µÄ¡¾Âß¼­Ö÷Ìå¡¿£¨ÎªÁËʵÏÖ²»Í¬µÄÂß¼­¹¦ÄÜ£©×éºÏÔÚÒ»ÆðµÄ£¬²Î¼ûÏÂͼ¡£ÕâÒ²½âÊÍÁËΪʲôÓÐЩ½Úµã£¨Èç/var£©¿ÉÒÔ¹Ò½Óµ½²»Í¬´ÅÅÌ·ÖÇøÉÏ¡£»®·ÖÕâЩÂß¼­²¿·Ö¶ÔÇåÎú°ÑÎÕ¸ùÎļþϵͳ½á¹¹£¬ÒÔ¼°Õû¸öϵͳµÄÐÐΪ¶¼Óкܴó ......

LinuxÉèÖû·¾³±äÁ¿Ð¡½á

1¡¢×ܽᱳ¾°
ÔÚlinuxϵͳÏ£¬Èç¹ûÄãÏÂÔز¢°²×°ÁËÓ¦ÓóÌÐò£¬ºÜÓпÉÄÜÔÚ¼üÈëËüµÄÃû³Æʱ³öÏÖ“command not found”µÄÌáʾÄÚÈÝ¡£Èç¹ûÿ´Î¶¼µ½°²×°Ä¿±êÎļþ¼ÐÄÚ£¬ÕÒµ½¿ÉÖ´ÐÐÎļþÀ´½øÐвÙ×÷¾ÍÌ«·±ËöÁË¡£ÕâÉæ¼°µ½»·¾³±äÁ¿PATHµÄÉèÖÃÎÊÌ⣬¶øPATHµÄÉèÖÃÒ²ÊÇÔÚlinux϶¨ÖÆ»·¾³±äÁ¿µÄÒ»¸ö×é³É²¿·Ö¡£±¾°¸Àý»ùÓÚRedHat AS4½² ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ