LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 02-02-2007, 11:26 PM   #1
ggeorgak
LQ Newbie
 
Registered: Aug 2006
Posts: 7

Rep: Reputation: 0
strange behavior using system() and ping utility


I am executing system("ping -c 1 -w 1 192.168.1.66"). Supposedly pinging stops either when an ECHO_REPLY has been received or the deadline of 1 second has passed. The strange thing is that the program keeps pinging even though both flags are violated, the scenario is that I have a lan node that gets connected and disconnected from the network. Using Ctrl+C to stop the ping fork process(meaning the system fork process I don't create a new one) I see that it keeps pinging meaning more ECHO_REQUESTS than 1 are sent and the time restriction of 1 second is definitely surpassed.Any ideas of why this is happening?

I forgot to mention that I'm using a SIGALRM handler to call a function that in turn calls system(...). Could this have to do anything with the problem? If yes in what way?

Last edited by ggeorgak; 02-02-2007 at 11:37 PM.
 
Old 02-03-2007, 01:10 AM   #2
jonwatson
Member
 
Registered: Jun 2004
Location: Nova Scotia, Canada!
Distribution: Ubuntu
Posts: 170

Rep: Reputation: 30
I have a similar script that works as expected. I don't have a space between the 'w' and the '1'. Try 'w1'.
 
Old 02-04-2007, 02:58 AM   #3
ggeorgak
LQ Newbie
 
Registered: Aug 2006
Posts: 7

Original Poster
Rep: Reputation: 0
I'm pretty sure that the signal handler of SIGALRM has something to do with the problem as using a pthread solved it.

Last edited by ggeorgak; 02-04-2007 at 03:51 AM.
 
Old 02-04-2007, 04:30 AM   #4
jonwatson
Member
 
Registered: Jun 2004
Location: Nova Scotia, Canada!
Distribution: Ubuntu
Posts: 170

Rep: Reputation: 30
Cool. Glad you got it running. How did you solve it?
 
Old 02-10-2007, 06:55 AM   #5
ggeorgak
LQ Newbie
 
Registered: Aug 2006
Posts: 7

Original Poster
Rep: Reputation: 0
I just used a pthread instead of a new process and everything worked out fine
 
  


Reply


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
Strange Ping Issue - Can't ping localhost but can ping others on LAN code_slinger Linux - Networking 13 03-17-2011 03:47 AM
Strange behavior of sound system hanasi Linux - Software 2 07-10-2005 08:22 AM
Ping utility gr33ndata Programming 3 02-17-2005 07:01 PM
Ping utility Wickedinterface Linux - Software 2 07-12-2004 07:30 PM
Incomprehensible ping behavior Gmiadlicher Linux - Networking 1 02-25-2004 04:07 PM


All times are GMT -5. The time now is 03:11 AM.

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