Skip to Content [alt-c]

Comment

In reply to Remote SSH Commands and Broken Connections

Reader Jamie on 2022-11-08 at 07:59:

Further to my above post, this is the equivalent function in FreeBSD:

#include <unistd.h> #include <signal.h> #include <sys/procctl.h>

int main (int argc, char **argv)

{ int signal_to_send = SIGTERM; procctl (P_PID, 0, PROC_PDEATHSIG_CTL, &signal_to_send); execvp (argv[1], argv + 1); return 127; }

As an aside, I note that when using TCSH as a login shell (also maybe others) on the remote machine, you need to preface the "diewithparent" with "exec", as otherwise tcsh spawns a further process and so you'd need to then use die-with-grandparent. (this is how it appears here, anyway)

It doesn't seem to make any difference with bourne shell, so there is no harm always doing it.

Reply

Post a Reply

Your comment will be public. To contact me privately, email me. Please keep your comment polite, on-topic, and comprehensible. Your comment may be held for moderation before being published.

(Optional; will be published)

(Optional; will not be published)

(Optional; will be published)

  • Blank lines separate paragraphs.
  • Lines starting with > are indented as block quotes.
  • Lines starting with two spaces are reproduced verbatim (good for code).
  • Text surrounded by *asterisks* is italicized.
  • Text surrounded by `back ticks` is monospaced.
  • URLs are turned into links.
  • Use the Preview button to check your formatting.