linux wait£¨£©²»Ìî²ÎÊý µÈ´ý×ÓÏß³Ì
#include <semaphore.h>
#include <unistd.h>
#include <stdio.h>
#include <fcntl.h>
void print(pid_t pid);
sem_t *sem;/*¶¨ÒåposixÓÐÃûÐźŵÆ*/
int val;/*¶¨ÒåÐźŵƵ±Ç°Öµ*/
int main(int argc,char *argv[])
{
int n=0;
if(argc!=2)
{
printf("please input a sem name!\n");
exit(1);
}
sem=sem_open(argv[1],O_CREAT,0644,2);/*´ò¿ªÒ»¸öÐźŵƣ¬³õÖµÉèΪ2*/
while(n++ <5)/*Ñ»·´´½¨5¸ö×Ó½ø³Ì£¬Ê¹ËûÃÇͬ²½ÔËÐÐ*/
{
if(fork()==0)
{
sem_wait(sem);/*ÉêÇëÐźŵÆ*/
print(getpid());/*µ÷Óù²Ïí´úÂë¶Î*/
sleep(1);
sem_post(sem);/*ÊÍ·ÅÐźŵÆ*/
printf("I'm finished,my pid is %d\n",getpid());
exit(0);//return 0;
}
}
wait();/*µÈ´ýËùÓÐ×Ó½ø³Ì½áÊø*/-----ÕâÀïwait¿ÉÒÔ²»Ìî²ÎÊýµÈ´ýËùÓÐ×Ó½ø³ÌÂð£¿
//while(wait(NULL)!= -1)
// ;
sem_close(sem);
sem_unlink(argv[1]);
printf("---reach here---\n");
exit(0);
}
void print(pid_t pid)
{
printf("I get it,my pid is %d\n",pid);
sem_getvalue(sem,&val);
printf("Now the semvalue is %d\n",val);
}
³ÌÐòÔËÐнá¹û£º
[ken@localhost 3]$ ./sem_in_mprocess test &
Ïà¹ØÎÊ´ð£º
дÁ˸ö²âÊÔ³ÌÐòÈçÏÂ
struct hostent *hp;
char AlarmDevIP[20];
int x2;
hp = gethostbyname("www.google.com");
if (hp)
{
......
Õ¾µãÏÂÓÐ×ÓÎļþ¼Ð script Îļþ¼ÐÏÂÓÐjsÎļþindex.js
¸ùĿ¼ÏÂÓÐÎļþindex.php
ÏëȨÏÞÉèÖóÉÖ±½Óͨ¹ýURL:http://www.abc.com/script/index.jsÎÞ·¨·ÃÎÊ,ÐèҪȨÏÞ
µ«ÊÇͨ¹ýindex.phpµ ......
СµÜ×î½üÐèÒªÒ»¸öÓÃsocket»ñÈ¡htmlÎĵµµÄ´úÂ룬µ«ÊÇÀÏÊDz»ÄÜ»ñÈ¡ÍêÕûµÄhtmlÔ´Âë¡£ÔÒò²»Ã÷£¬Íû¸ßÊÖÖ¸µã£¡
C/C++ code:
char *Http_GET(char *host,int port,char *data) //·¢ËÍGETÇëÇó
{
char response[2 ......
ÎÒ´ÓxpÓ²Å̰²×°ÁËfedora red£¬ÓÃgrub for dos°²×°³É¹¦£¬Æô¶¯ºóȴûÓÐlinuxµÄÆô¶¯Ï࣬ÊDz»ÊÇ»¹Òª×öЩÅäÖÃ
xp¿ÉÒÔÕý³£Æô¶¯£¬ÄÇλ´óϺ°ï°ï棬ÔÚÏߵȰ¡£¡
×Ô¼ºÏȶ¥ÏÂ
Æô¶¯ÏîÊÇÒª×Ô¼ºÊÖ¶¯Ìí¼ÓµÄ£¬ºÇºÇ
±à¼ºÃm ......