Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No child process error while using system() command

 
rasika deshpande
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rasika, welcome to Java Ranch!

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

Showing the code in question might also help.
 
rasika deshpande
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic