kill child Process, exec

27 views
Skip to first unread message

Hans Wurst

unread,
Apr 2, 2019, 2:44:46 PM4/2/19
to nodejs
Hello,

I need your help.
I want to get the public IP address of my Beaglebone via ifconfig.me.

If I have an existing internet connection it works fine. If I don't have an internet connection the request should be aborted. 
Here is my code:
function publicIP_www(callback){
  try{
     exec('curl ifconfig.me',{timeout:3000, killSignal:'SIGKILL'}, function(error, stdout, stderr){ 
     callback(stdout); }); 
  } 
  catch (err){
     callback("000.000.000.000");
  }
}

The returned IP address is then displayed on a web site in the browser. 
If there is no internet connection, the browser calculates forever. It seems as if the call exec ...... is not terminated.

I'm looking forward to your support and hope that someone can tell me what I'm doing wrong.

best regards 
Hans

Hans Wurst

unread,
Apr 3, 2019, 11:54:29 AM4/3/19
to nodejs
It's working! 
Also my variant. 

Thank you very much for your efforts.
I made a stupid mistake while testing. 

Reply all
Reply to author
Forward
0 new messages