Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-01-2002, 09:05 AM
|
#1
|
|
LQ Newbie
Registered: Oct 2002
Posts: 9
Rep:
|
Using the "system( )" system call causes exit sometimes
I am having a problem using system(..) function. I am trying to do a ifconfig using the
system(..) function however, the program exits in the call to the system(..) function.
I've tried this before in a different part of code and it did work. It somehow mysteriously doesn't seem to work anymore. I can still do a ifconfig call from the command line instead of doing from my code and that works just fine.
Any help is greatly appreciated.
Thanks for your time,
Abhi
|
|
|
|
10-01-2002, 10:37 AM
|
#2
|
|
LQ Addict
Registered: Dec 2001
Location: Brooklyn, NY
Distribution: *NIX
Posts: 3,704
Rep:
|
It is a very vague question, I have a car, and the thing is I can't started - possibilities:
1. You don't have an ignition key
2. You don't have an engine.
3. You don't have .... you got it
So please, we need more details, like for instance what language do you use? C, perl, bash scripting, etc.
|
|
|
|
10-01-2002, 10:54 AM
|
#3
|
|
LQ Newbie
Registered: Oct 2002
Posts: 9
Original Poster
Rep:
|
Sorry about that Neo. I'm a newbie posting a message for the first time. I'm sure you've figured that out by now
I am programming in C using Redhat 7.3. kernel 2.4.7-10. I have found something more upon debugging it further. It seems like the system(..) function call forks a process and executes the command within that process. In my case the command i am trying to execute is ifconfig. Upon executing the command this newly created process by the system (..) exits. The problem seems to be the way the signal handler is installed in my parent process i.e. the process that executes the system function call. I am pretty certain that the signal handler is causing the process to exit. I am in the process of finding that out for certain. Does that make more sense ? However, the question still remain why the same system("ipconfig sl0 172.16.17.xxx pointopoint 172.16.17.xxx") worked before. I am trying to set up a slip device using the ifconfig call.
Thanks for your time. Appreciate it. Hopefully, the new information makes more sense.
Abhi
|
|
|
|
10-01-2002, 11:19 AM
|
#4
|
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530
Rep: 
|
Guessing a bit...but maybe you started it as root and it worked. Now you start it as a regular user, and it doesn't work? The reason could be then that ifconfig is not in your $PATH. If this is the case, use the path from / i.e. system("/sbin/ifconfig");
|
|
|
|
10-01-2002, 11:45 AM
|
#5
|
|
LQ Newbie
Registered: Oct 2002
Posts: 9
Original Poster
Rep:
|
I've been running the program as root from the beginning and the ifconfig is in my $PATH. Either way i.e. /sbin/ifconfig or /ifconfig causes the exit to occur.
I just uninstalled my signal handler for SIGCHLD and it now WORKS. Still need to investigate how it worked before. The answer i guess may lie in my signal handler. I'll post a message once i get the whole thing figured out again. However, it suprises me that a call to the system("ifconfig...") generates a SIGCHLD. The process that makes the system call has no idea that a child was spawned and i would have assumed that it would not get the SIGCHLD. Another intersting thing is that if you don't catch the SIGCHLD, there is no zombie process created which i believe means that the system function did wait and collect the exit status of the child.
I debugged this using strace on the process. For future reference, is there a better way to trace such system calls.
Thanks again!!
|
|
|
|
10-01-2002, 02:42 PM
|
#6
|
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530
Rep: 
|
Quote:
|
The process that makes the system call has no idea that a child was spawned [...]
|
...but the kernel does, I think. (or is in "init"?)
|
|
|
|
10-01-2002, 02:56 PM
|
#7
|
|
LQ Addict
Registered: Dec 2001
Location: Brooklyn, NY
Distribution: *NIX
Posts: 3,704
Rep:
|
Look if there are any zombified processes running around, he-he.
ps -fuax |grep Z
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:31 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|