{
    "mode": "man",
    "parameter": "setsid",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/setsid/1/json",
    "generated": "2026-06-16T10:48:11Z",
    "synopsis": "setsid [options] program [arguments]",
    "sections": {
        "NAME": {
            "content": "setsid - run a program in a new session\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "setsid [options] program [arguments]\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "setsid runs a program in a new session. The command calls fork(2) if already a process group\nleader. Otherwise, it executes a program in the current process. This default behavior is\npossible to override by the --fork option.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "",
            "subsections": [
                {
                    "name": "-c --ctty",
                    "content": "Set the controlling terminal to the current one.\n",
                    "flag": "-c",
                    "long": "--ctty"
                },
                {
                    "name": "-f --fork",
                    "content": "Always create a new process.\n",
                    "flag": "-f",
                    "long": "--fork"
                },
                {
                    "name": "-w --wait",
                    "content": "Wait for the execution of the program to end, and return the exit status of this program\nas the exit status of setsid.\n",
                    "flag": "-w",
                    "long": "--wait"
                },
                {
                    "name": "-V --version",
                    "content": "Display version information and exit.\n",
                    "flag": "-V",
                    "long": "--version"
                },
                {
                    "name": "-h --help",
                    "content": "Display help text and exit.\n",
                    "flag": "-h",
                    "long": "--help"
                }
            ]
        },
        "AUTHORS": {
            "content": "Rick Sladkey <jrs@world.std.com>\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "setsid(2)\n",
            "subsections": []
        },
        "REPORTING BUGS": {
            "content": "For bug reports, use the issue tracker at https://github.com/karelzak/util-linux/issues.\n",
            "subsections": []
        },
        "AVAILABILITY": {
            "content": "The setsid command is part of the util-linux package which can be downloaded from Linux\nKernel Archive <https://www.kernel.org/pub/linux/utils/util-linux/>.\n\n\n\nutil-linux 2.37.2                            2021-06-02                                    SETSID(1)",
            "subsections": []
        }
    },
    "summary": "setsid - run a program in a new session",
    "flags": [
        {
            "flag": "-c",
            "long": "--ctty",
            "arg": null,
            "description": "Set the controlling terminal to the current one."
        },
        {
            "flag": "-f",
            "long": "--fork",
            "arg": null,
            "description": "Always create a new process."
        },
        {
            "flag": "-w",
            "long": "--wait",
            "arg": null,
            "description": "Wait for the execution of the program to end, and return the exit status of this program as the exit status of setsid."
        },
        {
            "flag": "-V",
            "long": "--version",
            "arg": null,
            "description": "Display version information and exit."
        },
        {
            "flag": "-h",
            "long": "--help",
            "arg": null,
            "description": "Display help text and exit."
        }
    ],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Run a program in a new session if the calling process is not a process group leader.",
        "examples": [
            {
                "description": "Run a program in a new session",
                "command": "setsid {{program}}"
            },
            {
                "description": "Run a program in a new session discarding the resulting output and error",
                "command": "setsid {{program}} > /dev/null 2>&1"
            },
            {
                "description": "Run a program creating a new process",
                "command": "setsid {{-f|--fork}} {{program}}"
            },
            {
                "description": "Return the exit code of a program as the exit code of setsid when the program exits",
                "command": "setsid {{-w|--wait}} {{program}}"
            },
            {
                "description": "Run a program in a new session setting the current terminal as the controlling terminal",
                "command": "setsid {{-c|--ctty}} {{program}}"
            }
        ]
    }
}