Video Coming Soon...

Created by Zed A. Shaw Updated 2026-11-26 20:48:52
 

54: nohup

WARNING: This is from the Go course but I'm rewriting the code and the description to fit C. If you want to attempt it go ahead. The challenge is the same, just no examples yet.

I really liked learning how to implement nohup in this course. nohup is a tool that does two extremely useful things:

  1. Capture all, and I mean all of the output, no matter how stupid the programmer of the other tool has become. Got a command line tool that insists on sending useful information to the error output? nohup.
  2. Keeps a command running even if your network connection or terminal crashes...on Unix. On Windows this maybe works? Maybe could work? I don't know.

The Challenge

To implement nohup you'll need one little package from the internet named "github.com/mattn/go-isatty". This package has two functions that will tell you if os.Stdout is attached to a terminal or not:

fd := os.Stdout.Fd()
is_atty := isatty.IsTerminal(fd) || isatty.IsCygwinTerminal(fd)

You'll also need to ignore the syscall.SIGHUP signal so that nohup keeps running even if the terminal closes:

signal.Ignore(syscall.SIGHUP)

I'm giving you this code because this is deeep Unix lore nobody remembers. I didn't even remember it and I've been using Unix for decades. Now you're on your own.

The documentation for nohup is here:

Previous Lesson Next Lesson

Register for From Impostor to Programmer

Register today for the course and get the all currently available videos and lessons, plus all future modules for no extra charge.