Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library
← Back to context

Comment by asveikau

4 years ago

closefrom() comes in handy for this. It's missing on some platforms (notably glibc and mac iirc) but actually not too hard to implement a work-alike.

1 comment

asveikau

Reply

cryptonector  4 years ago

I've copied a closefrom() many a time.

A common hack I've had to add is an argument FD that is not to be closed because. e.g., an flock is held on it.

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities