¹ÜµÀpipe——Linuxѧϰ±Ê¼Ç
¹ÜµÀ£ºµ±´ÓÒ»¸ö½ø³ÌÁ¬½ÓÊý¾ÝÁ÷µ½ÁíÒ»¸ö½ø³Ìʱ£¬Ê¹ÓÃÊõÓï¹ÜµÀ£¨pipe£©¡£
££i nclude <unistd.h>
int pipe(int filedes[2]); //´´½¨¹ÜµÀ
pipe()˵Ã÷:
·µ»ØÖµ£º0³É¹¦£¬-1³ö´í¡£
Èç¹ûµ÷Óóɹ¦£¬Ôò½ø³Ì´ËʱÓÉÁËÁ½¸ö¶îÍâµÄ´ò¿ªÎļþÃèÊö·û£¬filedes[0]ÖеÄÖµÊǹܵÀµÄ¶ÁÈ¡¶Ë£¬¶øfiledes[1]ÊǹܵÀµÄдÈë¶Ë¡£
#include<unistd.h>
#include<sys/types.h>
#include<errno.h>
#include<stdio.h>
#include<stdlib.h>
int main(){
int pipe_fd[2];
pid_t pid;
char buf_r[100];
char *p_wbuf;
int r_num;
memset(buf_r,0,sizeof(buf_r));
//´´½¨¹ÜµÀ
if(pipe(pipe_fd)<0){
printf("pipe create error\n");
return -1;
}
if((pid=fork())==0){//±íʾÔÚ×Ó½ø³ÌÖÐ
printf("\n");
//¹Ø±Õ¹ÜµÀдÃèÊö·û£¬½øÐйܵÀ¶Á²Ù×÷
close(pipe_fd[1]);
sleep(2);
//¹ÜµÀÃèÊö·ûÖжÁÈ¡
if((r_num=read(pipe_fd[0],buf_r,100))>0){
printf("%d numbers read from the pipe is %s\n",r_num,buf_r);
}
close(pipe_fd[0]);
exit(0);
}
else if(pid>0){
//±íʾÔÚ¸¸½ø³ÌÖУ¬¸¸½ø³Ìд
//¹Ø±Õ¹ÜµÀ¶ÁÃèÊö·û£¬½øÐйܵÀд²Ù×÷
close(pipe_fd[0]);
if(write(pipe_fd[1],"He
Ïà¹ØÎĵµ£º
×÷Õß: Óð·É | ·¢²¼Ê±¼ä: ÐÇÆÚÌì, 01/24/2010 - 16:23
ÔÚÍøÉÏÕÒÒ²ºÃ¶à¹ØÓÚÕâ·½ÃæµÄ×ÊÁÏ£¬µ«¶¼Ã»ÓÐÒ»¸ö¿ÉÒÔÓõģ¬
×Ô¼ºÑо¿ÁËһϣ¬ÍêÈ«¿ÉÒÔʵÏÖ£¬Ö»Òª°´ÕÕÒÔϲ½Öè×öÁË£¬°üÄãÄÜ°ÑCentOSÇë»Ø¼Ò
ƽ̨Windows XP£» ËùÐèÈí¼þgrub4dos-0.4.3.zip£» CentOS¾µÏñÎļþDVD¡£
1.ÔÚWindows X ......
¼òÒª½éÉÜ£º
Á´½ÓÓÐÁ½ÖÖ£¬Ò»ÖÖ±»³ÆΪӲÁ´½Ó£¨Hard Link£©£¬ÁíÒ»ÖÖ±»³ÆΪ·ûºÅÁ´½Ó£¨Symbolic
Link£©¡£ÈíÁ´½ÓÏ൱ÓÚwindowsÖеĿì½Ý·½Ê½£¬Ó²Á´½ÓÏ൱ÓÚÒ»¸öÊý¾Ýͬ²½±¸·Ý£¬Êý¾Ý´æ·ÅÔÚÁ½´¦£¬Ó븴ÖƲ»Í¬µÄÊÇÁ½´¦Ö®¼ä´æÔÚͬ²½»úÖÆ£¬Ò»´¦Êý¾ÝµÄ¸Ä±ä»áʵʱͬ²½µ½ÁíÒ»´¦,ÁíÍ⣬һ´¦Êý¾ÝÈç¹û±»É¾³ýÁË£¬²»»áÓ°Ïìµ½ÁíÒ»´¦µÄÊý¾Ý¡£
ÏÞ ......
zipÊǸöʹÓù㷺µÄѹËõ³ÌÐò£¬Îļþ¾ËüѹËõºó»áÁíÍâ²úÉú¾ßÓД.zip”À©Õ¹ÃûµÄѹËõÎļþ¡£
linux zip ÃüÁîÏê½â
¹¦ÄÜ˵Ã÷£ºÑ¹ËõÎļþ¡£
Óï·¨£ºzip [-AcdDfFghjJKlLmoqrSTuvVwXyz$][-b <¹¤×÷Ŀ¼>][-ll][-n <×Öβ×Ö·û´®>][-t <ÈÕÆÚʱ¼ä>][-<ѹËõЧÂÊ>][ѹËõÉú³ÉÎļþ][Ô´Îļþ][-i <·¶±¾ ......
4)º¯Êý
Èç¹ûÄúдÁËһЩÉÔ΢¸´ÔÓһЩµÄ³ÌÐò£¬Äú¾Í»á·¢ÏÖÔÚ³ÌÐòÖпÉÄÜÔÚ¼¸¸öµØ·½Ê¹ÓÃÁËÏàͬµÄ´úÂ룬²¢ÇÒÄúÒ²»á·¢ÏÖ£¬Èç¹ûÎÒÃÇʹÓÃÁ˺¯Êý£¬»á·½±ãºÜ¶à¡£Ò»¸öº¯ÊýÊÇÕâ¸öÑù×ӵģº
functionname()
{
# inside the body $1 is the first argument given to the function
# $2 the second ...
body
}
ÄúÐèÒªÔÚÿ¸ö³ÌÐ ......