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

LinuxÐźÅ

from: http://cc.byexamples.com/20070520/tap-the-interrupt-signal/
When you hit control+c, you are actually send a SIGINT ( Interrupt signal ) to your program. By default, your program will be terminated after receiving SIGINT. But you can change the way of handling Interrupt signal.
Some of the application tends to ignore SIGINT. You can easily do that with sigaction.
#include<stdio.h>
#include<signal.h>
void bypass_sigint(int sig_no)
{

}
int main()
{

struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = &bypass_sigint;
sigaction(SIGINT, &sa,NULL);

while(1)
{
sleep(1);
printf("do nothing \n ");
}
return 0;
}

Create a void function that intentionally do nothing. Create a sigaction structure variable, set the sa_handle point to the void fucntion. At last calling sigaction function, telling the system, while receiving SIGINT, call the void function.
Observed that the sigaction have to take 3 parameters, and the third param is to store the default sigaction structure for SIGINT. specify NULL for ignoring that.
What if I wanna tap the interrupt signal, do some operations and then allows the default SIGINT operation carry on? This can be very useful, for example, I want my program to log whatever in my memory to a file before the program terminate.
#include<stdio.h>
#include<signal.h>
#include<string.h>

struct sigaction osa;

void bypass_sigint(int sig_no)
{
printf("I tap SIGINT and returns back \n");
sigaction(SIGINT,&osa,NULL);
kill(0,SIGINT);
}

int main()
{

struct sigaction sa,osa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = &bypass_sigint;
sigaction(SIGINT, &sa,&osa);

while(1)
{
sleep(1);
printf("do nothing \n ");
}


Ïà¹ØÎĵµ£º

LinuxÃüÁ


1. ×î³£ÓõÄÃüÁîÁбí
ÏÂÃæÁгöÊ®¸öÔÚʹÓÃlinux¹ý³ÌÖÐʹÓÃÆµÂÊ×î¸ßµÄÃüÁî¡£ÕâÀïÖ»×÷¼òµ¥½éÉÜ£¬¾ßÌåÓ÷¨Çë²Î¿¼ºóÃæÄÚÈÝ¡£
cat£¬ÏÔʾÎļþÄÚÈÝ¡£
cd£¬¸Ä±äĿ¼·¾¶¡£
cp£¬¸´ÖÆÎļþ¡£
find£¬²éÕÒÎļþ¡£
grep£¬ËÑË÷¡¢¹ýÂËÐÅÏ¢¡£
ls£¬ÁгöĿ¼ÐÅÏ¢¡£
more£¬·ÖÒ³ÏÔʾ¡£
rm£¬É¾³ýÎļþ»òĿ¼¡£
vi£¬µ÷ÓÃviÎı¾±à¼­Æ÷ ......

linuxϵÄed ±à¼­Æ÷

linuxϵÄed ±à¼­Æ÷
ed ±à¼­Æ÷ÊÇ Linux ²Ù×÷ϵͳÏÂ×î¼òµ¥µÄÎı¾±à¼­Æ÷¡£ËüÊÇÒÔÐÐΪµ¥Î»¶ÔÎļþ½øÐб༭µÄ±à¼­Æ÷£¬¶ø²»Ïñ MS-DOS ϵͳÏ嵀 edit ÄÇÑùÊÇÒÔÕû¸öÆÁÄ»¿ò¼ÜΪµ¥Î»¶ÔÎļþ½øÐб༭µÄ¡£Òò´Ë£¬Èç¹ûÄãÒѾ­Ï°¹ßÁËʹÓà edit ÕâÖÖ·ç¸ñµÄ±à¼­Æ÷£¬ÄÇôÄã¿ÉÄÜÐèÒªÒ»¶Îʱ¼ä²ÅÄÜϰ¹ß ed µÄ·ç¸ñ¡£µ«ÊÇÕâ²¢²»ÖØÒª£¬ÒòΪ ed µÄ¼ò± ......

linuxϲ鿴nginx£¬apache£¬mysql£¬phpµÄ±àÒë²ÎÊý

ÒýÓÃhttp://www.linuxtone.org/html/76/t-2776.html
ÓÐʱºònginx£¬apache£¬mysql£¬php±àÒëÍêÁËÏë¿´¿´±àÒë²ÎÊý¿ÉÒÔÓÃÒÔÏ·½·¨
nginx±àÒë²ÎÊý£º
#/usr/local/nginx/sbin/nginx -V
CODE:
nginx version: nginx/0.6.32
built by gcc 4.1.2 20071124 (Red Hat 4.1.2-42)
configure arguments: --user=www --group=www --p ......

linux´ÅÅÌIO²é¿´

hiphop_linux
linux´ÅÅÌIO²é¿´(iostat)
##############
#
#    ²Ù×÷
#
##############
# iostat -x 1 10
Linux 2.6.18-92.el5xen    02/03/2009
avg-cpu:  %user   %nice %system %iowait  %steal   %idle
          ......

µÚÒ»´ÎÔÚLinuxϱà³Ì

µÚÒ»´ÎÔÚLinuxϱà³Ì¡£ºÇºÇ
ÔÚÍøÉÏËÑË÷ÁËÒ»ÏÂÔõôÑùÔÚLinuxϱà³Ì¡£ËµÊÇÓÃGeditдºÃ´úÂ룬Ȼºó±£´æ.c¸ñʽÎļþ¡£È»ºóµ½Öն˱àÒë¡£
´ò¿ªGedit.ÀÏ¹æ¾Ø£¬ÏÈÀ´¸öHello.c
#include <stdio.h>
main()
{
 printf("Hello~!Vimo~~\n\n");
}
±£´æ¡£È»ºó´ò¿ªÖÕ¶Ë¡£
±àÒëÊÇʲôÃüÁû°ì·¨£¬ÎÊÏÂͬѧ¡£°¢Á鏿ËßÎÒ£º ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ