Linux³ÌʽÉè¼Æ
http://www.openchess.org/noitatsko/programming/ (2001-05-24 16:47:48)
ÐźŴ¦Àí
--------------------------------------------------------------------------------
ÐźŴ¦Àí¸Å˵
ËͳöÐźÅ
½ÓÊÕÐźÅ
ÐźŵĴ¦Àí
ÈÎÎñ¿ØÖÆ
--------------------------------------------------------------------------------
POSIX IPC
reliable/unreliable
reentrant
pending
sending signals
catching signals
manipulating
signal definitions
--------------------------------------------------------------------------------
ÐźÅsingals
ÐźŵĴ¦Àí¿ÉÒÔÓÃÒ»´óÕÂÀ´Ð´£¬Éæ¼°µÄ²ãÃæÒ²»áÉîÈëÕû¸ö×÷ҵϵͳÖУ¬ÎÒ²¢²»´òËãÕâÑù×ö£¬ÒòΪÄú¿ÉÄÜ»áÔ½¸ãÔ½ÃÔºý¡£ÕâÀïÎÒÖ»¸æËßÄúÈçºÎ½ÓÉÏÐźţ¬ÔÚʵÓõIJãÃæÉÏ£¬ÕâÑù±ãºÜ¹»ÓÃÁË¡£Äú¿ÉÒÔÏÈÀûÓÃÕâЩ»ù±¾µÄ¼¼ÇÉÀ´×«Ð´³Ìʽ£¬µÈµ½ÓнøÒ»²½¸ßµÈÓ¦ÓõÄÐèҪʱ£¬ÕÒÒ»±¾½ÏÉîÈëµÄUNIX Programming½Ì²Ä£¬×¨ÃÅÑо¿signalµÄд·¨¡£
Ò»°ã¼òµ¥µÄsignalд·¨ÈçÏÂ:
void mysignal(int signo)
{
/* my signal handler */
}
void initsignal(void)
{
struct sigaction act;
act.sa_handler = mysignal;
act.sa_flags = 0;
sigemptyset(&act.sa_mask);
sigaction(SIGHUP,&act,NULL);
sigaction(SIGINT,&act,NULL);
sigaction(SIGQUIT,&act,NULL);
sigaction(SIGILL,&act,NULL);
sigaction(SIGTERM,&act,NULL);
}
ÀýÒ»: lock.c
ÔÚforkµÄÀýÈýÖÐÌáµ½£¬ÔÚdaemon±»É±µôʱ£¬ÐèÒªÔÚÀ뿪ǰ£¬½«/var/run/lock.pidɾ³ý¡£ÕâÀïÎÒÃÇ¿ÉÒÔÀûÓÃsignalÀ´´¦ÀíÕâ¼þÊ¡£
#include
#include
#include
#include
#define LOCK_FILE "/var/run/lock.pid"
void quit(int signo)
{
printf("Receive signal %d\n",signo);
unlink(LOCK_FILE);
exit
Ïà¹ØÎĵµ£º
linuxϵͳ°²È«(¶þ): ÈÕÖ¾
http://www.ibm.com/developerworks/cn/linux/security/l-ossec/part2/index.html
ÎĵµÑ¡Ïî
´òÓ¡±¾Ò³
½«´ËÒ³×÷Ϊµç×ÓÓʼþ·¢ËÍ
¼¶±ð£º ³õ¼¶
½úÁÁ (sound810@sina.com), ÍøÂ簲ȫ¹¤³Ìʦ
2003 Äê 1 ÔÂ 09 ÈÕ
ÎÒÃÇÖ÷Òª½²Ò»ÏÂLinux»·¾³ÖеÄϵͳ¼ÇÕʺÍϵͳÈÕÖ¾¹ÜÀíÒÔ¼°ÔõôÓÃÒ ......
LinuxÐÐÒµÕÐÆ¸¼¼ÊõÃæÊÔÌâ»ã×Ü
1. ÔÚLinuxϵͳÖУ¬ÒÔ Îļþ ·½Ê½·ÃÎÊÉ豸 ¡£
2. LinuxÄÚºËÒýµ¼Ê±£¬´ÓÎļþ /etc/fstab ÖжÁȡҪ¼ÓÔØµÄÎļþϵͳ¡£
3. LinuxÎļþϵͳÖÐÿ¸öÎļþÓà i½Úµã À´±êʶ¡£
4. È«²¿´ÅÅÌ¿éÓÉËĸö²¿·Ö×é³É£¬·Ö±ðΪÒýµ¼¿é ¡¢×¨ÓÃ¿é ¡¢ i½Úµã±í¿é ºÍÊý¾Ý´æ´¢¿é¡£
5. Á´½Ó·ÖΪ£º Ó²Á´½Ó ºÍ ·ûºÅÁ´½ ......
ÔÚ°²×°ºÃRedhatÒÔºó£¬ÐèÒªÉèÖÃFtpºÍTelnet·þÎñÎļþ£¬²ÅÄÜÆô¶¯FtpºÍTelnet·þÎñ£¬¿ÉÒÔͨ¹ýÔ¶³Ì¿ØÖƽøÐпªÆô¡£
¡¡¡¡1.1¡¢ÓÃrootÓû§µÇ¼£¬½øÈëÖÕ¶ËÃüÁîģʽ£»
¡¡¡¡1.2¡¢¿ªÆôftp·þÎñ¡£
¡¡¡¡cd /etc/xinetd.d £¬±à¼ftp·þÎñµÄÅäÖÃÎļþgssftpµÄÉèÖãº
¡¡¡¡¿ªÆôftp·þÎñÉèÖÃ.
¡¡¡¡vi gssftp £¬½« ÐÞ¸ÄÁ½ÏîÄÚÈÝ£º
¡¡¡¡£¨1£©ser ......
vim(vi)ÊÇLinuxÖй¦ÄÜÇ¿´óµÄ±à¼¹¤¾ß¡£vimÓÐ3ÖÐÖ÷ÒªµÄģʽ£º
1.normal mode£ºµ±½øÈëvimʱ£¬Ä¬ÈϵÄģʽ¾ÍÊÇnormal mode¡£ÔÚ´ËģʽÏ£¬ÎÞ·¨ÊäÈëÈκÎÎÄ×Ö£¬²»¹ý¿ÉÒÔÀûÓð´¼üÃüÁîÀ´Ö´ÐÐÐí¶à²Ù×÷ÃüÁÀýÈçÒÆ¶¯¹â±êλÖᢸ´ÖÆ¡¢É¾³ý¡£
2.insert mode£º½øÈëvimÊäÈëa¡¢i¡¢»òo¼ü¡£¼´¿É½øÈëinsert  ......