Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ÏÂPerl½Å±¾Á¬½ÓSQLServer

×¼±¸¹¤×÷:
¡¡¡¡Óõ½µÄperl À©Õ¹×é¼þ(modules)ÔÚÉÏÆªÌù³ö.( win32::odbc Ä£¿é
)ÏÂÔØ×é¼þºó°´ÕÕReadmeÎļþ°²×°µ¹ÏìӦĿ¼.ÅäÖúÃÏàÓ¦µÄodbcÊý¾ÝÔ´.
¡¡¡¡
¡¡¡¡³ÌÐòʵÏÖ:
¡¡¡¡Ê¹ÓÃ
¡¡¡¡use
Win32::ODBC;
¡¡¡¡
¡¡¡¡Óï¾ä°üº¬Ó¦Ê¹ÓõÄÄ£¿éÊÇwin32::odbc,д³öÊý¾Ý¿â
Á¬½Ó×Ö·û´®
¡¡¡¡
¡¡¡¡$DSN = "DSN =
My DSN ......

LinuxϵͳÉϰ²×°MYSQLÊý¾Ý¿â

Èç¹ûÊÇwinϵģ¬ÎÒ¸öÈËÍÆ¼öËÑË÷ÏÂÒ»¼ü°²×°°ü£¡ÎÒÓõľÍÊÇphp+mysql£¨×÷Õ߽УºÑ§Ï°À×·æºÃ°ñÑù£© °²×°Ò»ÏÂÈ«¶¼¿ÉÒÔÕý³£Ê¹ÓÃÁË£¬²»ÐèÒªµ÷Õû£¡
ÏÂÃæÊÇLinuxϰ²×°·½·¨£¡
¡¡1¡¢ÏÂÔØMySQLµÄ°²×°Îļþ
¡¡¡¡°²×°MySQLÐèÒªÏÂÃæÁ½¸öÎļþ£º
¡¡¡¡MySQL-server-5.0.26-0.i386.rpm
¡¡¡¡MySQL-client-5.0.26-0.i386.rpm
¡¡¡¡ÏÂÔØµØÖ·Î ......

LINUX½ø³ÌµÈÐÅÏ¢²é¿´

²é¿´·¢ÐаæÐÅÏ¢£º
lsb_release -a Õâ¸ö×îÏêϸ
²é¿´Äں˺ͲÙ×÷ϵͳλÊý£º
uname -a
64λ²Ù×÷ϵͳÓÐÀàËÆÐÅÏ¢£º.... x86_64 x86_64 x86_64...
32λ²Ù×÷ϵͳÓÐÀàËÆÐÅÏ¢£º.... i686 i686 i386...
²é¿´cpuÐÅÏ¢£º
more /proc/cpuinfo
²é¿´ºÍ¿ØÖÆÏµÍ³·þÎñ£¨Èç iptables·À»ðǽµÄ¿ªºÍ¹Ø£©£º
chkconfig ²é¿´ºÍÉ趨·þÎñÔÚ²»Í¬ ......

linux ssh ³£ÓÃÃüÁî

ssh³£ÓÃÃüÁî
Ŀ¼£º
1. Basic Instructions /»ù±¾Ö¸Áî
2. wget /ÏÂÔØ¹¤¾ß
3. Crontab /¶¨Ê±ÈÎÎñ
4. tar/tar.gz /ѹËõÎļþ
5. vi /±à¼­Æ÷
1. Basic Instructions»ù±¾²Ù×÷ÃüÁî
ͨ³£À´Ëµ£¬Ê¹ÓÃ"$[Instructions] --help"¿ÉÒÔ»ñµÃÒÔϸ÷¸öÃüÁî[instructions]µÄ°ïÖú£¬°üº¬Æä²ÎÊýÁбíµÄ¶¨Òå¡£
-ls Áгöµ±Ç°Îļþ¼Ð ......

linux ²é¿´ CPU£¬ÄÚ´æ£¬ÍøÂçÁ÷Á¿ºÍ´ÅÅÌ I/O

ʹÓÃvmstatÃüÁîÀ´²ì¿´ÏµÍ³×ÊÔ´Çé¿ö
ÔÚÃüÁîÐз½Ê½Ï£¬ÈçºÎ²é¿´CPU¡¢ÄÚ´æµÄʹÓÃÇé¿ö£¬ÍøÂçÁ÷Á¿ºÍ´ÅÅÌI/O£¿
Q: ÔÚÃüÁîÐз½Ê½Ï£¬ÈçºÎ²é¿´CPU¡¢ÄÚ´æµÄʹÓÃÇé¿ö£¬ÍøÂçÁ÷Á¿ºÍ´ÅÅÌI/O£¿
A: ÔÚÃüÁîÐз½Ê½Ï£¬
1. ²é¿´CPUʹÓÃÇé¿öµÄÃüÁî
""ÿ5ÃëË¢ÐÂÒ»´Î£¬×îÓÒ²àÓÐCPUµÄÕ¼ÓÃÂʵÄÊý¾Ý
$ vmstat 5
""top È»ºó°´Shift+P£¬°´ÕÕ½ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ