Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 04-11-2011, 04:04 AM   #1
Registered: Jan 2011
Posts: 53

Rep: Reputation: 0
Question Help regarding popen() and pclose()

hi folks,

iam a newbie to linux environment iam using popen() to run script(s) in thread(s)

all i need is my scripts should execute in parallel without starving for cpu and log the results(of scripts) in to log.

here i cannt use pclose because it will close process as well as pipe opened by popen (), i need to use this pipe for logging later.

so i did following code change in my code to acheive popen(),pclose() functionality.

is there any pitfaults/leaks with my code if so please let me know.

int main ()
char buf[128]={0};
int pid;
int status;

Fp = popen("./", "r");


if ( waitpid((pid_t)pid,&status,0) <0)
printf("wait failed:\n");


return 0;

it is working fine but i need to know above code effects in complete process(i mean run time errors).

thx in adv



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
python 2.6.4 os.popen os.system jabfinger Programming 2 02-26-2010 10:22 AM
Help using popen and execl cdog Linux - Software 3 02-28-2007 06:44 PM
popen for windows csfalcon Programming 6 11-30-2005 08:21 AM
popen output not appear dimsh Programming 4 10-22-2005 02:56 AM
C Popen gold5angel Programming 2 04-17-2004 07:07 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:52 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration