5

So, I have a sudoer account in a remote host, in which I create a process with thousands of threads and sockets. The thing is, if I create too many threads/sockets (not sure which one, it might even be some other limit), I get locked out of the host: my ssh connection is lost and, if I try to ssh back in, I get a Write failed: Broken pipe error message.

How can I get back into the system, other than asking some other user to sudo killall -9 -u myusername in that machine? The host is normally accessible to other users.

6
  • So.. why do you create thousands of threads in the first place? Why don't you raise the limits with sysctl?
    – Apache
    Jul 17, 2012 at 10:34
  • Well, maybe I shouldn't spawn so many threads, but I think that might be a separate discussion. So, let's assume that I have to create so many threads. But I don't think the number of threads is the problem... it's probably something else. Jul 17, 2012 at 10:39
  • 1
    If 65535 ports of your system are busy, there is no way. You should hard reboot it. if not maybe this help: ssh user@computer "kill -9 processUid" Write in just one line. It just try to ssh and then kill the proccess. I didn't get it, Can you ssh with another user?
    – Hamed JML
    Jul 17, 2012 at 10:49
  • I couldn't send the kill command with ssh because ssh would have to open a brief session for my user, which isn't possible. Other users can ssh normally into the system, but then I'd have to ask them. I have no other user account for myself there. Jul 17, 2012 at 11:58
  • 1
    if you had a time frame on how long it takes before you reach the limit. you could create yourself a "AT" task to post a tty message letting you know your about to restart your session and auto kill the session with kill -9 processUid, then just relog in.. if working with critical data you could script this all out with methods to save where your at in said data and execute the script with "AT".
    – tao
    Aug 14, 2012 at 17:47

1 Answer 1

1

At the moment your limit is reached, you can't do anything except the solution you provided (ask another user to kill your processes).

To prevent this in the future, you will need to find out what limit is actually reached and then the the limit for your process slightly lower than the maximum (using ulimit). You may also consider using cgroups (Linux control groups) to isolate your process in such a way that it won't consume all resources.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .