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

Linux ÐźÅsignal´¦Àíº¯Êý


×î½ü×öµÄ¶«Î÷»¹ÕæÊÇÔÓÂÒÎÞÕÂ,  Óеã¸ú²»ÉϽø¶È,½Ó´¥µÄ¶¼ÊÇδ֪µÄ¶«Î÷.¼ÌÐøÀ©³ä..
alarm£¨ÉèÖÃÐźŴ«ËÍÄÖÖÓ£©
Ïà¹Øº¯Êý signal£¬sleep
±íÍ·Îļþ #include<unistd.h>
¶¨Ò庯Êý unsigned int alarm(unsigned int seconds);
º¯Êý˵Ã÷ alarm()ÓÃÀ´ÉèÖÃÐźÅSIGALRMÔÚ¾­¹ý²ÎÊýsecondsÖ¸¶¨µÄÃëÊýºó´«Ë͸øÄ¿Ç°µÄ½ø³Ì¡£Èç¹û²ÎÊýseconds Ϊ0£¬Ôò֮ǰÉèÖõÄÄÖÖӻᱻȡÏû£¬²¢½«Ê£ÏµÄʱ¼ä·µ»Ø¡£
·µ»ØÖµ·µ»ØÖ®Ç°ÄÖÖÓµÄÊ£ÓàÃëÊý£¬Èç¹û֮ǰδÉèÄÖÖÓÔò·µ»Ø0¡£
·¶Àý #include<unistd.h>
#include<signal.h>
void handler() {
printf("hello\n");
}
main()
{
int i;
signal(SIGALRM,handler);
alarm(5);
for(i=1;i<7;i++){
printf("sleep %d ...\n",i);
sleep(1);
}
}
Ö´ÐÐ sleep 1 ...
sleep 2 ...
sleep 3 ...
sleep 4 ...
sleep 5 ...
hello
sleep 6 ...
¡¡
kill£¨´«ËÍÐźŸøÖ¸¶¨µÄ½ø³Ì£©
Ïà¹Øº¯Êý raise£¬signal
±íÍ·Îļþ #include<sys/types.h>
#include<signal.h>
¶¨Ò庯Êý int kill(pid_t pid,int sig);
º¯Êý˵Ã÷ kill()¿ÉÒÔÓÃÀ´ËͲÎÊýsigÖ¸¶¨µÄÐźŸø²ÎÊýpidÖ¸¶¨µÄ½ø³Ì¡£²ÎÊýpidÓм¸ÖÖÇé¿ö:
pid>0 ½«ÐźŴ«¸ø½ø³Ìʶ±ðÂëΪpid µÄ½ø³Ì¡£
pid=0 ½«ÐźŴ«¸øºÍĿǰ½ø³ÌÏàͬ½ø³Ì×éµÄËùÓнø³Ì
pid=-1 ½«ÐźŹ㲥´«Ë͸øÏµÍ³ÄÚËùÓеĽø³Ì
pid<0 ½«ÐźŴ«¸ø½ø³Ì×éʶ±ðÂëΪpid¾ø¶ÔÖµµÄËùÓнø³Ì
²ÎÊýsig´ú±íµÄÐźűàºÅ¿É²Î¿¼¸½Â¼D
·µ»ØÖµ Ö´Ðгɹ¦Ôò·µ»Ø0£¬Èç¹ûÓдíÎóÔò·µ»Ø-1¡£
´íÎó´úÂë EINVAL ²ÎÊýsig ²»ºÏ·¨
ESRCH ²ÎÊýpid ËùÖ¸¶¨µÄ½ø³Ì»ò½ø³Ì×é²»´æÔÚ
EPERM ȨÏÞ²»¹»ÎÞ·¨´«ËÍÐźŸøÖ¸¶¨½ø³Ì
·¶Àý #include<unistd.h>
#include<signal.h>
#include<sys/types.h>
#include<sys/wait.h>
main()
{
pid_t pid;
int status;
if(!(pid= fork())){
printf("Hi I am child process!\n");
sleep(10);
return;
}
else{
printf("send signal to child process (%d) \n",pid);
sleep(1);
kill(pid ,SIGABRT);
wait(&status);
if(WIFSIGNALED(status))
printf("chile process receive signal %d\n",WTERMSIG(status));
}
}
Ö´ÐÐ sen signal to child process(3170)
Hi I am child process!
child process receive signal 6
pause£¨Èýø³ÌÔÝÍ£Ö±µ½ÐźųöÏÖ£©
Ïà¹Øº¯Êý kill£¬signal£¬sleep
±íÍ·Îļþ #include<unistd.h>
¶¨


Ïà¹ØÎĵµ£º

ʵսLinux Bluetooth±à³Ì£¨Èý£© HCI²ã±à³Ì

1. HCI²ãЭÒé¸ÅÊö£º
HCIÌṩһÌ×ͳһµÄ·½·¨À´·ÃÎÊBluetoothµ×²ã¡£ÈçͼËùʾ£º
´ÓͼÉÏ¿ÉÒÔ¿´³ö£¬Host Controller Interface(HCI)  ¾ÍÊÇÓÃÀ´¹µÍ¨HostºÍModule¡£Hostͨ³£¾ÍÊÇPC£¬ ModuleÔòÊÇÒÔ¸÷ÖÖÎïÀíÁ¬½ÓÐÎʽ£¨USB,serial,pc-cardµÈ£©Á¬½Óµ½PCÉϵÄbluetooth Dongle¡£
ÔÚHostÕâÒ»¶Ë£ºapplication,SDP,L2capµÈЭÒé ......

ʵսLinux Bluetooth±à³Ì£¨ËÄ£© L2CAP²ã±à³Ì

£¨L2CAPЭÒé¼ò½é£¬L2CAPÔÚBlueZÖеÄʵÏÖÒÔ¼°L2CAP±à³Ì½Ó¿Ú£©
Ò»£ºL2CAPЭÒé¼ò½é£º
Logical Link Control and Adaptation Protocol(L2CAP)
Âß¼­Á¬½Ó¿ØÖƺÍÊÊÅäЭÒé (L2CAP) ΪÉϲãЭÒéÌá¹©ÃæÏòÁ¬½ÓºÍÎÞÁ¬½ÓµÄÊý¾Ý·þÎñ£¬²¢Ìṩ¶àЭÒ鹦ÄܺͷָîÖØ×é²Ù×÷¡£L2CAP ³äÐíÉϲãЭÒéºÍÓ¦ÓÃÈí¼þ´«ÊäºÍ½ÓÊÕ×î´ó³¤¶ÈΪ 64K µÄ L2CAP Ê ......

ʵսLinux Bluetooth±à³Ì(Áù) L2CAP±à³ÌʵÀý

ÀýÒ»£º·¢ËÍSignaling Packet£º
Signaling CommandÊÇ2¸öBluetoothʵÌåÖ®¼äµÄL2CAP²ãÃüÁî´«Êä¡£ËùÒÔµÃSignaling CommandʹÓÃCID 0x0001.
¶à¸öCommand¿ÉÒÔÔÚÒ»¸öC-frame£¨control frame£©Öз¢ËÍ¡£
 Èç¹ûÒªÖ±½Ó·¢ËÍSignaling Command.ÐèÒª½¨Á¢SOCK_RAWÀàÐ͵ÄL2CAPÁ¬½ÓSocket¡£ÕâÑù²ÅÓлú»á×Ô¼ºÌî³äCommand Code£¬Identi ......

LinuxÏÂͨ¹ýiptablesץȡtcpÁ¬½Ó

1.1.1   iptablesÔ­Àí
 
1.1.2   ÒÔ±¾µØÎªÔ´µÄ°ü·¾¶
Step
Table
Chain
Comment
1
 
 
±¾µØ³ÌÐò£¨±ÈÈ磬·þÎñ³ÌÐò»ò¿Í»§³ÌÐò£©
2
 
 
·ÓÉÅжϣ¬ÒªÊ¹ÓÃÔ´µØÖ·£¬Íâ³ö½Ó¿Ú£¬»¹ÓÐÆäËûһЩÐÅÏ¢¡£
3
mangle
OUTPUT
ÔÚÕâ¶ù¿ÉÒÔmangle°ü¡£½¨Òé²»ÒªÔÚÕâ¶ù×ö¹ýÂË£¬¿ ......

LinuxÏÂÍøÂç¹¥»÷DDosµÄʵÏÖ´úÂ룬tcpÊý¾ÝÆÛÆ­µÄʵÏÖ

/*
×¢Ò⣺
Õâ´ÎÖ÷Òª¸ÄÁ˺¯Êýsend_tcpÀïµÄ´úÂ룬¾ÉµÄ´úÂëÔÚÌî³äip°üʱÓÐÎÊÌâ¡£
*/
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/ip.h>
#include <netinet/tcp.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <st ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ