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 µÄ±ê×¼º¯Êý¿âÖ
Ïà¹ØÎĵµ£º
linuxÈíÖжϻúÖÆ
ÖжϷþÎñ³ÌÐòÍùÍù¶¼ÊÇÔÚCPU¹ØÖжϵÄÌõ¼þÏÂÖ´Ðеģ¬ÒÔ±ÜÃâÖжÏǶÌ×¶øÊ¹¿ØÖƸ´ÔÓ»¯¡£µ«ÊÇCPU¹ØÖжϵÄʱ¼ä²»ÄÜÌ«³¤£¬·ñÔòÈÝÒ×¶ªÊ§ÖжÏÐźš£Îª´Ë£¬ Linux½«ÖжϷþÎñ³ÌÐòÒ»·ÖΪ¶þ£¬¸÷³Æ×÷“Top Half”ºÍ“Bottom Half”¡£Ç°Õßͨ³£¶Ôʱ¼äÒªÇó½ÏΪÑϸñ£¬ ......
ÖÐÎİæÊéÄ¿
¡¶Apache CookbookÖÐÎİ棨µÚ¶þ°æ£©¡· New!
¡¶Linux Networking CookbookÖÐÎİ桷 New!
¡¶Shell½Å±¾Ñ§Ï°Ö¸ÄÏ¡· New!
¡¶×¿ÓгÉЧµÄ³ÌÐòÔ±¡· New!
¡¶´úÂëÖ®ÃÀ¡· New!
¡¶Ç¶ÈëʽӲ¼þÉè¼Æ£¨µÚ¶þ°æ£©¡· New!
¡¶LPI LinuxÈÏ֤ȨÍþÖ¸ÄÏ£¨µÚ¶þ°æ£©¡· New!
¡¶LINUX SERVER HACKS£¨¾í¶þ£©¡· New!
¡¶BSD Hacks¡· ......
ÈçºÎÓÃÓï¾äɱËÀËùÓÐ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ÍøÂçÇý¶¯³ÌÐòÖÐÐèҪעÒâµÄÎÊÌâ
¡¡¡¡3.1 ÖжϹ²Ïí
¡¡¡¡LinuxϵͳÔËÐм¸¸öÉ豸¹²Ïíͬһ¸öÖжϡ£ÐèÒª¹²ÏíµÄ»°£¬ÔÚÉêÇëµÄʱºòÖ¸Ã÷¹²Ïí·½Ê½¡£ÏµÍ³ÌṩµÄrequest_irq()µ÷Óõ͍Ò壺
¡¡¡¡¡¡¡¡int request_irq(unsigned int irq,
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡void (*handler)(int irq, void *dev_id, struct pt_regs *re ......
A simple unix/linux daemon in Python
http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/
by Sander Marechal
I've
written a simple Python class for creating daemons on unix/linux
systems. It was pieced together for various other examples, mostly
corrections to various Py ......