Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTRL-C no longer stops a running program. #419

Closed
rwaldron opened this issue Oct 27, 2015 · 13 comments
Closed

CTRL-C no longer stops a running program. #419

rwaldron opened this issue Oct 27, 2015 · 13 comments

Comments

@rwaldron
Copy link
Contributor

Control C ends the open process locally, but doesn't terminate the remote process.

@johnnyman727
Copy link
Contributor

@rwaldron could this be the same issue as #345?

@HipsterBrown
Copy link
Contributor

I think this is a different issue where the Node program running on Tessel doesn't stop after control+C is pressed. I ran into the same issue once when running a server on Tessel and couldn't run new code because the port was still being used. I had to ssh in and kill the process manually.

@rwaldron
Copy link
Contributor Author

rwaldron commented Dec 8, 2015

I ran into the same issue once when running a server on Tessel and couldn't run new code because the port was still being used.

That's not Tessel specific, it's the nightmare EADDRINUSE error.

@johnnyman727
Copy link
Contributor

Anecdotally, I believe this is just a LAN issue.

@johnnyman727
Copy link
Contributor

I'm unable to reproduce this issue over USB but it's consistent over LAN. I've spent about an hour trying every possible way to close the SSH connection but I'm thinking it's either an issue with the ssh2 lib or with how OpenWRT manages SSH connections.

I've opened a relevant issue on the ssh2 dependency with a smaller test case here: mscdex/ssh2#382

Worst case, I suppose we can add another command t2 stop to stop runaway scripts? :shrugs:

@johnnyman727
Copy link
Contributor

Potentially relevant: if I run a command with ssh built in to OSX and close the output, the process continues after aborting...:

ssh -i ~/.tessel/id_rsa root@Hen.local node /tmp/remote-script/__tessel_program__.js

Anyone else have an idea how to tell it to stop on SSH connection ending?

@johnnyman727
Copy link
Contributor

Figured it out from this stack exchange question. By adding -t -t to my ssh command in the terminal, it closed the process when I SIGINT'ed. The SSH manpage notes that -t is used for "psuedo-tty allocation". I looked up the ssh2 docs for something related to that and, sure enough, there is a pty option for exec. When set to true, the process is closed properly. PR coming up.

@johnnyman727
Copy link
Contributor

Fixed by #515.

@sdaitzman
Copy link

I'm experiencing this error on my brand new Tessel 2. Let me know which logs to send your way 😃

I have an app that starts an Express server and I currently get EADDRINUSE every time I run the program the second (or more than second) time.

@johnnyman727
Copy link
Contributor

@sdaitzman can you share the code you're running that's hitting this issue? Thanks!

@sdaitzman
Copy link

@johnnyman727 I found my issue 😄

I was using https://github.com/rgbkrk/atom-script to run my code. When I CTRL-C'd the panel the logs appeared in, it seems that the program continued running on the Tessel. I think this is an issue with that package, not t2 itself.

@johnnyman727
Copy link
Contributor

👍 That's a sweet plugin. A little menu for deploying to Tessel in Atom would be awesome too.

@rwaldron
Copy link
Contributor Author

Folks, let's be clear: EADDRINUSE is not the same as ^C not working :P

There are a few ways to avoid this:

  • Ensure that your server is closed on SIGINT:
process.on("SIGINT", _ => server.close());
  • Make "random" ports every time the program runs:
var port = process.env.PORT || (function() {
  return (Math.random() * (4000 - 3000) + 3000) | 0;
})();

server.listen(port, function () {
  var host = os.hostname();
  var domain = host.includes('local') ? '' : '.local';
  console.log(`http://${host}${domain}:${port}`)
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants