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>
¶¨
Ïà¹ØÎĵµ£º
1.1.1 iptablesÔÀí
1.1.2 ÒÔ±¾µØÎªÔ´µÄ°ü·¾¶
Step
Table
Chain
Comment
1
±¾µØ³ÌÐò£¨±ÈÈ磬·þÎñ³ÌÐò»ò¿Í»§³ÌÐò£©
2
·ÓÉÅжϣ¬ÒªÊ¹ÓÃÔ´µØÖ·£¬Íâ³ö½Ó¿Ú£¬»¹ÓÐÆäËûһЩÐÅÏ¢¡£
3
mangle
OUTPUT
ÔÚÕâ¶ù¿ÉÒÔmangle°ü¡£½¨Òé²»ÒªÔÚÕâ¶ù×ö¹ýÂË£¬¿ ......
system-config-printer ͼÐνçÃæÉèÖôòÓ¡»ú
BSD(FreeBSD)/System V
lpr/lp ´òÓ¡ÎļþÃû ´òÓ¡
lpr -P´òÓ¡»úÃû ´òÓ¡ÎļþÃû
lp &nb ......
LinuxϱàÒëºÍ²¿ÊðJavaWeb³ÌÐò½Å±¾
Ŀ¼½á¹¹ÈçÏ£º
|
|---- YourProject
| |-------- WebRoot
| |   ......
ÔÚ Ubuntu Linux ÖÐÓÃÔ´ÂëÎļþ°²×°Èí¼þʱ¾³£¶¼»áÓõ½chmodÃüÁîÀ´¸ü¸ÄÎļþµÄȨÏÞʹÆäÔÚ°²×°Ê±ÓÐÖ´ÐеÄȨÏÞ¡£ÓÉÓÚ Ubuntu Linux ĬÈϲ»ÄÜÓÃrootÕË»§À´µÇ¼ËùÒÔÔÚÓÃchmodÃüÁîÀ´¸ü¸ÄÎļþµÄȨÏÞʱÍùÍùÐèÒª½áºÏsudoÃüÁîÀ´Ê¹Óã¬Èç¹ûÄã¶ÔsudoÃüÁ²»Ì«Á˽⣬ÇëÏÈ¿´¿´±¾Õ¾µÄ¡¶sudoÃüÁîÏê½â¡·
chmod
Linux/Ubuntu ϵͳÖÐÎļþµ÷ ......
ij¸öÈÕ¼ûÖØÒªµÄÍøÂçоƬ¹«Ë¾¼´½«ÊÕ¹ºÒ»¼Ò×îÔçµãÉÌÒµ»¯Ç¶ÈëʽLinux µÄ¹«Ë¾¡£ Cavium ¹«Ë¾ÒÑͬÒâÖ§¸¶5000 ÍòÃÀÔª¸øÒѾ¶ÀÁ¢ÔËÐÐÊ®ÄêÖ®¾ÃµÄ MontaVista ¹«Ë¾¡£
ÕâÊǽñÄêµÚ¶þÀýǶÈëʽLinux ²Ù×÷ϵͳ¡¢¹¤¾ß¼°·þÎñÊг¡µÄ²¢¹º°¸Àý¡£µÚÒ»ÀýÊÇÔÚ½ñÄêÎåÔ£¬µ±Ê±Ó¢Ìضû»¨·Ñ 88400 ÍòÃÀÔªÊÕ¹º Wind River ϵͳ¹«Ë¾¡£ÈçͬWind River ÊÕ ......