File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes No child process error while using system() command Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "No child process error while using system() command" Watch "No child process error while using system() command" New topic
Author

No child process error while using system() command

rasika deshpande
Greenhorn

Joined: Mar 19, 2010
Posts: 2
Hi
I am getting errno:10 No child process error while using system() command. I tried doing wait(NULL) in parent but could not get success.
Can you please suggest me a way to resolve this error. Its urgent.

Thanks in advance.

Regards
Rasika
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Rasika, welcome to Java Ranch!

What do you mean by "system() command"?

Showing the code in question might also help.


JBoss In Action
rasika deshpande
Greenhorn

Joined: Mar 19, 2010
Posts: 2
Hey thanks....
Actually I'm using system() command to get the output of "df" command in child process but I'm getting error as "No child process".

I'm redirecting output of system() command to file and then reading from it in parent process. I tried using waitpid() in parent process. But it didn't help.

Here is a piece of code.




Thanks and Regards
Rasika.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Ahah! You never said your app was written in C! I assumed Java. I'll defer to a C expert for the answer.

By the way, please use the 'code' tags when posting source, makes it much easier to read.
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

Raiska --

This code isn't complete (many variables like stat, prcfre, and pid are undeclared), so I imagine there are all sorts of things that might go wrong with those declarations; but I think the main problem is that the syntax for your df command is wrong. That "%s" looks like it's intended to be a replaceable parameter -- i.e., a format string for the sprintf() command. You're not replacing the parameter with anything, though, and so df is going to fail. The "no child process" could definitely come from that.

So do you want df to report the usage of a particular filesystem, or all filesystems, or what?


[Jess in Action][AskingGoodQuestions]
 
jQuery in Action, 2nd edition
 
subject: No child process error while using system() command