Re: lug-bg: pipes
- Subject: Re: lug-bg: pipes
- From: sn@xxxxxxxxx (Svetoslav Nikolov)
- Date: Mon, 17 Apr 2000 08:21:14 +0200
Ne mojesh li da izpolzvash semafori, ili naprimer message queue za da
razberesh koga e prikliuchil child-procesa?
A inache ako child procesa startira programa, toi moje da proveriava
dali programata ne e svurshila chrez slednite niakolko reda :
/* Create one way pipe line with call to popen() */
if (( pipe_fp = popen("pidof program_name", "r")) == NULL)
{
perror("popen");
exit(1);
}
fgets(readbuf,80,pipe_fp);
fgets(readbuf,80,pipe_fp);
pclose(pipe_fp);
V readbuf-a shte se sadarja ID-to na programata. Sled kato child
procesa e ustanovil che programata se e zatvorila moje da prati
specialnata kombinacia ot simvoli. Sashtata proverka moje da se pravi
i ot parent procesa, stiga da znae imeto na programata.
Reshenieto ne e cufnalo ot elegantnost, no na men mi varshi rabota.
Svetoslav
On Sun, 16 Apr 2000, Luben Karavelov wrote:
> Abe znam che ne mu e bash tuk miastoto na tova
> suobshtenie ama da popitam:
> Ima slednata situacia - edin process se e fork-nal
> i obshtuva s child-prcessa chrez pipe - chete informaciata,
> koiato child-processa mu podava. no v edin moment informaciata,
> svurshva (koeto e normalno) i child-processa zatvaria ot
> svoiata strana pipe-a i izliza s exit(0). da obache parent
> processa ne moze da ustanovi tova (ili pone az ne znam kak)
> i prodylzhava da chaka oshte info ot child-processa. v rezultat
> na koeto child-processa zavisva kato <defunct>, a parent-a
> produlzhava da si chaka.
> znachi az se probvah da hvana koga izliza child-processa
> chrez
> while ((c=fgetc(stream)!=EOF)){ ...
> ili ... } while (!feof(stream));
> a sushto i i=read(dilesescr,&char,sizeof(char));
> } while (i>0);
> i kakvo li oshte ne probvah ama ne stava.
> problema ne e v bibliotekite, probvah go na libc5,
> glibc2.1.2 i glibc2.1.3, a iavno problema e v men.
> ta ako niakoi se e sbluskval s podoben problem ili ima
> niakava ideia za tova kak moze da se napravi tova neka
> pomogne.
>
> 10x predvaritelno
> Luben
>
> P.S. Edinstvenoto reshenie koeto izmislih e child-processa da pass-va
> niakakva specialna stoinost, kato da rechem "\n\n", ama v moya sluchai
> tova ne vurshi rabota, shtoto child-processa exec-va drug fail. To ne
> che tozi kudeto se izpulniava ot child-processa ne moga da go promenia
> ama tova izovshto ne e chisto reshenie.
> ==================================================================
> A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers)
> Otpiswaneto RABOTI !!! : Majordomo@xxxxxxxxxxxxxxxxxx UNSUBSCRIBE LUG-BG
> http://www.linux-bulgaria.org/ Hosted by Internet Group Ltd. - Stara Zagora
--
=====================================================
Svetoslav Nikolov
Dept. of Information Technology
Build. 344, room 209
Technical University of Denmark
DK-2800 Lyngby, Denmark
E-mail: sn@xxxxxxxxx
Phone : +45 45 25 37 05
Fax : +45 45 88 01 17
URL : http://www.it.dtu.dk/~sn
=====================================================
==================================================================
A mail-list of Linux Users Group - Bulgaria (bulgarian linuxers)
Otpiswaneto RABOTI !!! : Majordomo@xxxxxxxxxxxxxxxxxx UNSUBSCRIBE LUG-BG
http://www.linux-bulgaria.org/ Hosted by Internet Group Ltd. - Stara Zagora
- Относно:
- lug-bg: pipes
- Изпратено от: luben@xxxxxxxxxxxxx (Luben Karavelov)
|