13

I mean I can't use it in bash, is it not available on OS X, or is it just missing on my Mac?

It's not a PATH variable issue, because I searched with find command, and there's no file named setsid on my Mac at all.

If it's missing on OS X, is there any alternative to it? Or if it's the case that I somehow deleted it accidentally, where can I find a copy of it?

Nathaniel_Wu
  • 171
  • 1
  • 7
  • This should be part of the XCode command line tools. Have you installed them? – user3207838 Apr 13 '16 at 07:06
  • @user3207838 Yes, I have Xcode installed already, and "xcode-select --install" returns that command line tools are already installed. – Nathaniel_Wu Apr 14 '16 at 07:34
  • Ahem, isn't [setsid(2)](https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man2/setsid.2.html) a system call and not a runnable program? –  Apr 14 '16 at 09:02
  • 4
    @SamiLaine I know why this is now, it's a runnable program on many other *nix OSes, but it's missing in FreeBSD, thus OS X doesn't have that either. – Nathaniel_Wu Apr 22 '16 at 16:57
  • 2
    "Missing" implies that it *should* be available. POSIX specifies the C function for `setsid` program, but the command-line utility is purely an extension -- no OS vendor is *obligated* to provide it. – Charles Duffy Dec 29 '17 at 03:52

2 Answers2

10

use Brew:

brew install util-linux
Tiw
  • 5,078
  • 13
  • 24
  • 33
prodriguez903
  • 141
  • 1
  • 4
  • I've just tried this to no avail either: `brew install util-linux` Warning: util-linux 2.34 is already installed and up-to-date To reinstall 2.34, run brew reinstall util-linux; `which setsid` returns prompt, but $PATH set correctly. Found but not tried https://github.com/tzvetkoff/setsid-macosx – volvox Oct 04 '19 at 08:18
  • 3
    When installing it: `util-linux is keg-only, which means it was not symlinked into /usr/local, because macOS provides the uuid.h header.` Which is a bit sad, but... To run it, you can either invoke it directly: `/usr/local/opt/util-linux/bin/setsid` Or add these to `/usr/local/bin` (I do this, but it's not recommended as Homebrew prefers to manage this itself): `ln -s /usr/local/opt/util-linux/bin/* /usr/local/bin/` – David Cuthbert Jan 01 '20 at 20:57
  • 1
    If you wish to add the binaries to your PATH, be sure to follow the instructions at the end (It is not done automatically, unlike most brew packages) – Jordan Réjaud Nov 03 '20 at 04:55
2

Yes. /usr/bin/setsid is missing on Mac OS/X.

The OS interface is available, so based on the chapter 2 man page there may be some hope for porting the Linux source to Darwin.

J_H
  • 10,963
  • 1
  • 18
  • 34