err_sys() is something you have to provide yourself, though, which takes you out of the flow of the code you're thinking about, which is half the reason people don't write error handling in the first place.
Once I discovered the existence of the BSD err()/errx()/warn() functions, though, the error handling in even my quick one-off programs became much better and more informative.
pid_t child = fork();
if (child < 0) {
err("fork");
} else if (child == 0) {
... in child
} else {
... in parent
}
is idiomatic, quick to write, and produces useful error messages when that "throwaway" program starts failing years later.
Once I discovered the existence of the BSD err()/errx()/warn() functions, though, the error handling in even my quick one-off programs became much better and more informative.
is idiomatic, quick to write, and produces useful error messages when that "throwaway" program starts failing years later.