linux½ø³Ì¿ØÖÆ£exit£¨£©
http://blog.chinaunix.net/u1/53053/showart_425191.html
#include<stdlib.h>
void exit(int status);
²»ÏñforkÄÇôÄÑÀí½â£¬´ÓexitµÄÃû×Ö¾ÍÄÜ¿´³ö£¬Õâ¸öϵͳµ÷ÓÃÊÇÓÃÀ´ÖÕÖ¹Ò»¸ö½ø³ÌµÄ¡£ÎÞÂÛÔÚ³ÌÐòÖеÄʲôλÖã¬Ö»ÒªÖ´Ðе½exitϵͳµ÷Ó㬽ø³Ì¾Í»áֹͣʣϵÄËùÓвÙ×÷£¬Çå³ý°üÀ¨PCBÔÚÄڵĸ÷ÖÖÊý¾Ý½á¹¹£¬²¢ÖÕÖ¹±¾½ø³ÌµÄÔËÐС£Çë¿´ÏÂÃæµÄ³ÌÐò£º
/* exit_test1.c */
#include<stdlib.h>
main()
{
printf("this process will exit!\n");
exit(0);
printf("never be displayed!\n");
}
±àÒëºóÔËÐУº
$gcc exit_test1.c -o exit_test1
$./exit_test1
this process will exit!
ÎÒÃÇ¿ÉÒÔ¿´µ½£¬³ÌÐò²¢Ã»ÓдòÓ¡ºóÃæµÄ"never be displayed!\n"£¬ÒòΪÔÚ´Ë֮ǰ£¬ÔÚÖ´Ðе½exit(0)ʱ£¬½ø³Ì¾ÍÒѾÖÕÖ¹ÁË¡£
exit ϵͳµ÷ÓôøÓÐÒ»¸öÕûÊýÀàÐ͵IJÎÊýstatus£¬ÎÒÃÇ¿ÉÒÔÀûÓÃÕâ¸ö²ÎÊý´«µÝ½ø³Ì½áÊøʱµÄ״̬£¬±ÈÈç˵£¬¸Ã½ø³ÌÊÇÕý³£½áÊøµÄ£¬»¹ÊdzöÏÖijÖÖÒâÍâ¶ø½áÊøµÄ£¬Ò»°ãÀ´Ëµ£¬0±íʾûÓÐÒâÍâµÄÕý³£½áÊø£»ÆäËûµÄÊýÖµ±íʾ³öÏÖÁË´íÎ󣬽ø³Ì·ÇÕý³£½áÊø¡£ÎÒÃÇÔÚʵ¼Ê±à³Ìʱ£¬¿ÉÒÔÓÃwaitϵͳµ÷ÓýÓÊÕ×Ó½ø³ÌµÄ·µ»ØÖµ£¬´Ó¶øÕë¶Ô²»Í¬µÄÇé¿ö½øÐв»Í¬µÄ´¦Àí¡£¹ØÓÚwaitµÄÏêϸÇé¿ö£¬ÎÒÃǽ«ÔÚÒÔºóµÄƪ·ùÖнøÐнéÉÜ¡£
exitºÍ_exit
×÷Ϊϵͳµ÷ÓöøÑÔ£¬_exitºÍexitÊÇÒ»¶ÔÂÏÉúÐֵܡ£
ÕâʱËæ±ãÒ»¸ö¶®µÃCÓïÑÔ²¢ÇÒÍ·ÄÔÇåÐѵÄÈ˶¼»á˵£¬_exitºÍexitûÓÐÈκÎÇø±ð£¬µ«ÎÒÃÇ»¹Òª½²Ò»ÏÂÕâÁ½ÕßÖ®¼äµÄÇø±ð£¬ÕâÖÖÇø±ðÖ÷ÒªÌåÏÖÔÚËüÃÇÔÚº¯Êý¿âÖеĶ¨Òå¡£_exitÔÚLinuxº¯Êý¿âÖеÄÔÐÍÊÇ£º
#include<unistd.h>
void _exit(int status);
ºÍexit±È½Ïһϣ¬exit()º¯Êý¶¨ÒåÔÚ stdlib.hÖУ¬¶ø_exit()¶¨ÒåÔÚunistd.hÖУ¬´ÓÃû×ÖÉÏ¿´£¬stdlib.hËƺõ±Èunistd.h¸ß¼¶Ò»µã£¬ÄÇô£¬ËüÃÇÖ®¼äµ½µ×ÓÐʲôÇø±ðÄØ£¿ÈÃÎÒÃÇÏÈÀ´¿´Á÷³Ìͼ£¬Í¨¹ýÏÂͼ£¬ÎÒÃÇ»á¶ÔÕâÁ½¸öϵͳµ÷ÓõÄÖ´Ðйý³Ì²úÉúÒ»¸ö½ÏΪֱ¹ÛµÄÈÏʶ¡£
´ÓͼÖпÉÒÔ¿´³ö£¬_exit()º¯ÊýµÄ×÷ÓÃ×îΪ¼òµ¥£ºÖ±½Óʹ½ø³ÌÍ£Ö¹ÔËÐУ¬Çå³ýÆäʹÓõÄÄÚ´æ¿Õ¼ä£¬²¢Ïú»ÙÆäÔÚÄÚºËÖеĸ÷ÖÖÊý¾Ý½á¹¹£»exit()º¯ÊýÔòÔÚÕâЩ»ù´¡ÉÏ×÷ÁËһЩ°ü×°£¬ÔÚÖ´ÐÐÍ˳ö֮ǰ¼ÓÁËÈô¸ÉµÀ¹¤Ðò£¬Ò²ÊÇÒòΪÕâ¸öÔÒò£¬ÓÐЩÈËÈÏΪexitÒѾ²»ÄÜËãÊÇ´¿´âµÄϵͳµ÷Óá£
exit()º¯ÊýÓë_exit()º¯Êý×î´óµÄÇø±ð¾ÍÔÚÓÚexit()º¯ÊýÔÚµ÷ÓÃexitϵͳµ÷ÓÃ֮ǰҪ¼ì²éÎļþµÄ´ò¿ªÇé¿ö£¬°ÑÎļþ»º³åÇøÖеÄÄÚÈÝд»ØÎļþ£¬¾ÍÊÇͼÖеēÇåÀíI/O»º³å”Ò»Ïî¡£
ÔÚLinux µÄ±ê×¼º¯Êý¿âÖ
Ïà¹ØÎĵµ£º
ÈçºÎÓÃÓï¾äɱËÀËùÓÐoracle´ø(LOCAL=NO)µÄ½ø³Ì£¿
·½·¨Ò»£º(½øÈëoracleÓû§ÏÂ)
$ a=`ps -ef |grep oracle$ORACLE_SID|grep LOCAL=NO |awk '{print $2}'`
»òÕß (È¥³ýµ±Ç°grep½ø³Ì)
$ a=`ps -ef |grep oracle$ORACLE_SID|grep LOCAL=NO |grep -v grep|awk '{print $2}'`
$ echo $a
$ kill -9 $a
·½·¨¶þ£º£¨Ö±½Óɱ£©
$ p ......
Linux Îļþϵͳ¸ÅÊö
×÷Õߣº±±ÄÏÄϱ±
À´×Ô£ºLinuxSir.Org
ÕªÒª£º ±¾ÎÄͨ¹ýÎļþϵͳµÄ¶¨Òå˵Æð£¬È»ºóͨ¹ýÒýÎļòµ¥µÄ½éÉÜÁËÒ»ÏÂÎļþϵͳÀàÐÍ£»¶ÔLinux³£ÓõÄext2¡¢ext3¼°reiserfs ¸ù¾Ý±¾ÈËʹÓþÑéÒ²·º·ºµÄ̸ÁË̸£¬µ«²¢²»ÊÇרҵµÄ¡£ÈçºÎÔĶÁ±¾ÎÄ£¬»¹ÊÇÓÃÂí¿Ë˼ÀíÂÛ¸æËßÎÒÃǵķ½·¨£ºÒ»·ÖΪ¶þ£¬±ß¿´±ßÅú°É£»
Ŀ¼Ë÷Òý
Ò» ......
¡¡2.4 ³£ÓõÄϵͳ֧³Ö
¡¡¡¡2.4.1 ÄÚ´æÉêÇëºÍÊÍ·Å
¡¡¡¡include/linux/kernel.hÀïÉùÃ÷ÁËkmalloc()ºÍkfree()¡£ÓÃÓÚÔÚÄÚºËģʽÏÂÉêÇëºÍÊÍ·ÅÄÚ´æ¡£
¡¡¡¡void *kmalloc(unsigned int len,int priority);
¡¡¡¡void kfree(void *__ptr);
¡¡¡¡ÓëÓû§Ä£Ê½ÏµÄmalloc()²»Í¬£¬kmalloc()Éê ......
ÃüÁî
1.
file
×÷Óãº
file ͨ¹ý̽²âÎļþÄÚÈÝÀ´ÅжÏÎļþÀàÐÍ¡£
ʹÓÃfileÃüÁî¿ÉÒÔÖªµÀij¸öÎļþ¾¿¾¹ÊǶþ½øÖÆ(ELF¸ñʽ)µÄ¿ÉÖ´ÐÐÎļþ, »¹ÊÇShell scrīptÎļþ,»òÕßÊÇÆäËüµÄʲô¸ñʽ¡£fileÄÜʶ±ðµÄÎļþÀàÐÍÓÐĿ¼¡¢Shell½Å±¾¡¢Ó¢ÎÄÎı¾¡¢¶þ½øÖÆ¿ÉÖ´ÐÐÎļþ¡¢CÓïÑÔÔ´Îļþ¡¢Îı¾Îļþ¡¢DOSµÄ¿ÉÖ´ÐÐÎļþ¡£ ÐèҪ˵Ã÷µÄÊÇ,fileà ......
DWORD GetLocalAddr(char* interface)
{
struct ifreq ifr;
int fd;
int err;
unsigned long ip;
strcpy(ifr.ifr_name, interface);
fd = socket(AF_INET, SOCK_DGRAM, 0);
err = ioctl ......