Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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ϵÄed ±à¼­Æ÷

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

linux ssh ³£ÓÃÃüÁî

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

Linux·¢Ëͺ¯Êýdev_queue_xmit·ÖÎö

µ±Éϲã×¼±¸ºÃÒ»¸ö°üÖ®ºó£¬½»¸øÏÂÃæÕâ¸öº¯Êý´¦Àí
int dev_queue_xmit(struct sk_buff *skb)
{
struct net_device *dev = skb->dev;
struct netdev_queue *txq;
struct Qdisc *q;
int rc = -ENOMEM;
/* GSO will handle the following emulations directly. */
if (netif_needs_gso(dev, skb))
goto gso; ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ