2 ms·
Stevens and Rago, "Advanced Programming in the Unix Environment, Volume II", page 211,212. if ((pid = fork()) < 0) err_sys("fork error"); is idiomatic in Unix.
by ajarmst 12y ago
Stevens and Rago, "Advanced Programming in the Unix Environment, Volume II", page 211,212.
if ((pid = fork()) < 0) err_sys("fork error"); is idiomatic in Unix.
- wiml 12y agoerr_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.