LinuxÖÐwaitÓ÷¨
LinuxÖÐwaitÓ÷¨£º
ϵͳÖеĽ©Ê¬½ø³Ì¶¼ÒªÓÉwaitϵͳµ÷ÓÃÀ´»ØÊÕ¡£
º¯ÊýÔÐÍ£º
#include<sys/types.h>
#include<sys/wait.h>
pid_t wait(int *status);
½ø³ÌÒ»µ©µ÷ÓÃÁËwait¾ÍÁ¢¼´×èÈû×Ô¼º£¬ÓÉwait×Ô¶¯·ÖÎöÊÇ·ñµ±Ç°½ø³ÌµÄij¸ö×Ó½ø³ÌÒѾÍ˳ö£¬Èç¹ûÈÃËüÕÒµ½ÁËÕâÑùÒ»¸öÒѾ±ä³É½©Ê¬µÄ×Ó½ø³Ì£¬wait¾Í»áÊÕ¼¯Õâ¸ö×Ó½ø³ÌµÄÐÅÏ¢£¬²¢°ÑËü³¹µ×Ïú»Ùºó·µ»Ø£»Èç¹ûûÓÐÕÒµ½ÕâÑùÒ»¸ö×Ó½ø³Ì£¬wait¾Í»áÒ»Ö±×èÈûÔÚÕâÀֱµ½ÓÐÒ»¸ö³öÏÖΪֹ¡£
²ÎÊýstatusÓÃÀ´±£´æ±»ÊÕ¼¯½ø³ÌÍ˳öʱµÄһЩ״̬£¬ËüÊÇÒ»¸öÖ¸ÏòintÀàÐ͵ÄÖ¸Õë¡£µ«Èç¹ûÎÒÃǶÔÕâ¸ö×Ó½ø³ÌÊÇÈçºÎËÀµôºÁ²»ÔÚÒ⣬ֻÏë°ÑÕâ¸ö½©Ê¬½ø³ÌÏûÃðµô£¬£¨ÊÂʵÉϾø´ó¶àÊýÇé¿öÏ£¬ÎÒÃǶ¼»áÕâÑùÏ룩£¬ÎÒÃǾͿÉÒÔÉ趨Õâ¸ö²ÎÊýΪNULL£¬¾ÍÏñÏÂÃæÕâÑù£º
pid = wait(NULL);
Èç¹û³É¹¦£¬wait»á·µ»Ø±»ÊÕ¼¯µÄ×Ó½ø³ÌµÄ½ø³ÌID£¬Èç¹ûµ÷Óýø³ÌûÓÐ×Ó½ø³Ì£¬µ÷Óþͻáʧ°Ü£¬´Ëʱwait·µ»Ø-1£¬Í¬Ê±errno±»ÖÃΪECHILD¡£
Àý×Ó£º
/*wait.c*/
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
int main()
{
pid_t pc, pr;
pc = fork();
if ( pc < 0 ) /* Èç¹û³ö´í */
{
printf("create child prcocess error: %s\n", strerror(errno));
exit(1);
}
else if ( pc == 0) /* Èç¹ûÊÇ×Ó½ø³Ì */
{
printf("I am child process with pid %d \n", getpid());
sleep(3);/* ˯Ãß3ÃëÖÓ */
exit(0);
}
else /* Èç¹ûÊǸ¸½ø³Ì */
&nbs
Ïà¹ØÎĵµ£º
¹²ÏíÎļþϵͳÎļþ´«Ê䣬ÊÇÍøÂçÕì¿ØÏîÄ¿ÖеÄÒ»¸öʵ¼Ê²Ù×÷¡£ËüÊÇΪÁ˵ÖÖÆÈëÇÖÕß½øÈëÄÚÍø¶øÌá³öµÄÒ»ÖÖ°²È«½â¾ö·½°¸¡£ÔÚʵ¼Ê´«Êä¹ý³ÌÖУ¬ÍØÆËͼÈçÏ£º
ʵ¼Ê»·¾³¾ùÔÚLinuxÖ÷»úϽøÐС£²ÉÓÃOCFS2Îļþ¼¯ÈºµÄ·½Ê½¡£ÍⲿÖ÷»úAºÍÄÚ²¿Ö÷»úBÖ®¼äµÄͨѶ£¬¾ùͨ¹ý¹²Ïí´æ´¢¿Õ¼äC½øÐнÓÊܺͷ¢ËÍ¡£ÕâÑù¼´Ê¹ÈëÇÖÕßÄÃÏÂÍⲿÖ÷»úA£¬Ò²ÎÞ·¨Éø͸ÄÚ ......
Ò»¡¢Óû§¹ÜÀí»ù´¡
ÔÚLinux»·¾³Ï¶ÔÓû§µÄ¹ÜÀíÓжàÖÖ·½Ê½£¬°üÀ¨Óñ༹¤¾ßVi¡¢emacsµÈ¶Ô/etc/passwd½øÐвÙ×÷»òÖ±½ÓʹÓÃ
addusr¡¢deleusrµÈÓû§¹ÜÀíÃüÁîÒÔ¼°Ê¹ÓÃpwconvÃüÁîʹ/etc/passwdÓëshadowÎļþ±£³ÖÒ»Ö¡£ÎÒÃÇÏÈÀ´¿´¿´LinuxÏÂÓÃ
»§¹ÜÀíµÄ³£ÓòÙ×÷¶¼×öÁËЩʲô°É¡£
1¡¢Ôö¼ÓÓû§
Ôö¼ÓÓû§ÓÐÈý¸ö¹ý³Ì:
(1) ÔÚ/etc ......
#wget http://ftp.isc.org/isc/bind9/9.6.1-P1/bind-9.6.1-P1.tar.gz
#tar zxvf bind-9.6.1-P1.tar.gz
#cd bind-9.6.1-P1
#./configure --prefix=/usr/local/named --enable-threads --disable-openssl-version-check --disable-ipv6
#make && make install
#cd /usr/local/named
#sbin/rndc-confgen > e ......
1.ÅäÍøÂç
<1># vi /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO×Ô¶¯Îªdhcp¾²Ì¬¸ÄΪstatic
¼´£ºBOOTPROTO=static
IPADDR=?
NETMASK=?
GATEWAY=?
ÎÒµÄÅäÖÃÈçÏ£º
DEVICE=eth0
BOOTPROTO=static
IPADDR=10.10.19.234s
NETMASK=255.255.254.0
GETEWAY=10.10.18.254
ONBOOT=yes
TYPE=Ethernet
×¢£ ......