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

linux C forkº¯Êý

´´½¨Ð½ø³Ì£ºforkº¯Êý
1.1.1. forkº¯Êý¸Éʲô£¿
     #include <sys/types.h>
     #include <unistd.h>
     pid_t fork(void);
      ‘fork()’º¯ÊýÓÃÓÚ´ÓÒÑ´æÔÚ½ø³ÌÖд´½¨Ò»¸öнø³Ì¡£Ð½ø³Ì³ÆΪ×Ó½ø³Ì£¬¶øÔ­½ø³Ì³ÆΪ¸¸½ø³Ì¡£Äã¿ÉÒÔͨ¹ý¼ì²é‘fork()’º¯ÊýµÄ·µ»ØÖµÖªµÀÄĸöÊǸ¸½ø³Ì£¬ÄĸöÊÇ×Ó½ø³Ì¡£¸¸½ø³ÌµÃµ½µÄ·µ»ØÖµÊÇ×Ó½ø³ÌµÄ½ø³ÌºÅ£¬¶ø×Ó½ø³ÌÔò·µ»Ø0¡£ÒÔÏÂÕâ¸ö·¶Àý³ÌÐò˵Ã÷ËüµÄ»ù±¾¹¦ÄÜ£º
     pid_t pid;
     switch (pid = fork())
     {
     case -1:
         /* ÕâÀïpidΪ-1£¬forkº¯Êýʧ°Ü */
         /* һЩ¿ÉÄܵÄÔ­ÒòÊÇ */
         /* ½ø³ÌÊý»òÐéÄâÄÚ´æÓþ¡ */
         perror("The fork failed!");
         break;
     case 0:
         /* pidΪ0£¬×Ó½ø³Ì */
         /* ÕâÀÎÒÃÇÊǺ¢×Ó£¬Òª×öʲô£¿ */
         /* ... */
         /* µ«ÊÇ×öÍêºó, ÎÒÃÇÐèÒª×öÀàËÆÏÂÃ棺 */
         _exit(0);
     default:
         /* pid´óÓÚ0£¬Îª¸¸½ø³ÌµÃµ½µÄ×Ó½ø³ÌºÅ */
         printf("Child's pid is %d\n",pid);
     }
      µ±È»£¬ÓÐÈË¿ÉÒÔÓÑif() ... else ...’Óï¾äÈ¡´ú‘switch()’Óï¾ä£¬µ«ÊÇÉÏÃæµÄÐÎʽÊÇÒ»¸öÓÐÓõĹßÓ÷½·¨¡£
ÖªµÀ×Ó½ø³Ì×Ô¸¸½ø³Ì¼Ì³Ðʲô»òδ¼Ì³Ðʲô½«ÓÐÖúÓÚÎÒÃÇ¡£ÏÂÃæÕâ¸öÃûµ¥»áÒòΪ²»Í¬UnixµÄʵÏÖ¶ø·¢Éú±ä»¯£¬ËùÒÔ»òÐí׼ȷÐÔÓÐÁËË®·Ý¡£Çë×¢Òâ×Ó½ø³ÌµÃµ½µÄÊÇÕâЩ¶«Î÷µÄ *¿½±´*£¬²»ÊÇËüÃDZ¾Éí¡£
ÓÉ×Ó½ø³Ì×Ô¸¸½ø³Ì¼Ì³Ðµ½£º
½


Ïà¹ØÎĵµ£º

Linux iptableÎĵµ

×ÜÀÀ
ÓÃiptables -ADC À´Ö¸¶¨Á´µÄ¹æ
Ôò
£¬-AÌí¼Ó -Dɾ³ý -C ÐÞ¸Ä
iptables - [RI] chain rule num rule-specification[option]
ÓÃiptables - RI ͨ¹ý¹æÔòµÄ˳ÐòÖ¸¶¨
iptables -D chain rule num[option]
ɾ³ýÖ¸¶¨¹æÔò
iptables -[LFZ] [chain][option]
ÓÃiptables -LFZ Á´Ãû [Ñ¡Ïî]
iptables -[NX] chain
ÓÃ -NX ......

windowsÔ¶³ÌÖ´ÐÐlinux£¨ÃüÁîÐгÌÐò+ͼÐγÌÐò£©

×¼±¸¹¤×÷£º
1.Xming£¨windowsÔËÐÐx-windowsµÄÖ§³Ö£©
2.SecureCRTV6.5.8.380ºº»¯ÂÌÉ«Æƽâ°æ
¿ÉÒÔÈ¥ÎÒµÄhttp://download.csdn.net/johnvikeyÏÂÔØ
Èç¹ûÊÇÃüÁîÐÐÖ±½ÓÓÃ
SecureCRT
Èç¹ûÊÇÒªÔËÐÐͼÐγÌÐò
1.Xming£¨windowsÔËÐÐx-windowsµÄÖ§³Ö£©
2.SecureCRTV6.5.8.380ºº»¯ÂÌÉ«Æƽâ°æ
¶¼ÒªÊ¹ÓÃ
———&m ......

Linux ÃæÊÔ


Ìî¿Õ²¿·Ö
1
ÔÚlinux
ϵͳÖУ¬ÒÔÎļþ
µÄ·½Ê½·ÃÎÊÉ豸¡£
2 linux
ÄÚºËÒýµ¼Ê±£¬Í¨¹ý/etc/fstab
Îļþ¶ÁÈ¡Òª¼ÓÔصÄÎļþϵͳ
3 linux
ÎļþϵͳÖпÉÒÔÓÐÁ½ÖÖ·½Ê½±êʶÎļþÀàÐÍ£¬µÚÒ» ÖÖʹÓÃÑÕÉ«
À´±êʶ£¬°×É«±íʾһ°ãÐÔµÄÎļþ£¬ÈçÎı¾Îļþ¡¢ÅäÖÃÎļþ¡¢Ô´´úÂëÎļþµÈ£»Ç³ À¶É«µÄ±íʾÁ¬½ÓÎļþ£¬Ö»ÒªÊÇʹÓÃln
ÃüÁÁ¢µÄÎ ......

ACM cº¯Êý´óÈ«

º¯ÊýÃû: abs ¹¦  ÄÜ: ÇóÕûÊýµÄ¾ø¶ÔÖµ
Óà ·¨: int abs(int i);
³ÌÐòÀý:
#include <stdio.h>
#include <math.h>
int main(void)
{
  int number = -1234;
  printf("number: %d  absolute value: %d\n", number, abs(number));
  return 0;
}
º¯ÊýÃû: atof
¹¦  ......

TCP£¨SOCKETS£©±à³Ì C/C++ʵÏÖ

ͨÐÅ
Server£º
#pragma comment(lib, "ws2_32.lib")
#include <Winsock2.h>
#include <stdio.h>

void main()
{
//°æ±¾Ð­ÉÌ
WORD wVersionRequested;
WSADATA wsaData;
int err;

wVersionRequested = MAKEWORD(1,1); //0x0101
err = WSAStartup ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ