I get this message from systemd status after I have stopped my service:

Actice: failed (Result: exit-code) <...> Main PID: 4747 (code=exited, status=202/FDS)

Status FDS is defined in the docs like this:

202 EXIT_FDS Failed to close unwanted file descriptors, or to adjust passed file descriptors.

Starting the service works fine, no errors are reported by systemd status


  1. What does EXIT_FDS mean in more practical detail?
  2. Is the status code from my application, or from systemd itself?
  3. My application opens a TCP socket, which it doesn't close when stopped. Is that the reason?
  4. If so, can I make systemd ignore the lingering socket and not report it as an error?


The full status message:

tool-user@tool-box:~$ systemctl status tool.service
● tool.service - Tool application
   Loaded: loaded (/home/tool-user/tool.service; linked; vendor preset: enabled)
   Active: failed (Result: exit-code) since Mon 2022-02-07 14:14:46 CET; 3s ago
  Process: 4758 ExecStop=/bin/bash -c tool-stop && while ps -p $MAINPID >/dev/null
  Process: 4601 ExecStart=/bin/bash -c tool-start (code=exited, status=0/SUCCESS)
 Main PID: 4747 (code=exited, status=202/FDS)

Feb 07 14:14:31 tool-box systemd[1]: Starting Tool application...
Feb 07 14:14:32 tool-box bash[4601]: Server started on port 44680
Feb 07 14:14:32 tool-box systemd[1]: Started Tool application.
Feb 07 14:14:44 tool-box systemd[1]: Stopping Tool application...
Feb 07 14:14:45 tool-box systemd[1]: tool.service: Main process exited, code=exited, status=202/FDS
Feb 07 14:14:46 tool-box systemd[1]: tool.service: Failed with result 'exit-code'.
Feb 07 14:14:46 tool-box systemd[1]: Stopped Tool application.

The service definition file looks like this:

Description=Tool application
# Standard dependencies for web server
After=network.target remote-fs.target nss-lookup.target httpd-init.service

ExecStart=/bin/bash -c 'toolStart'
ExecStop=/bin/bash -c 'toolStop && while ps -p $MAINPID >/dev/null 2>&1; do sleep 1; done'


OS: Ubuntu 18.04 Server, run in VirtualBox on Windows 10.

tool-user@tool-box:~$ uname -a
Linux tool-box 4.15.0-166-generic #174-Ubuntu SMP Wed Dec 8 19:07:44 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

1 Answer 1


Since the service has Type=forking, the ExecStart process had PID 4758 and the exit code you're asking about is listed with main PID 4747, we can conclude that systemd managed to fork() a child process which then successfully execve()'d the ExecStart process, and so the table of systemd-specific exit codes does not apply here.

The systemd-specific table of exit codes would apply if the error was from the actual systemd child process after the fork() but before the execve(): specifically, error 202 would mean e.g. a problem in implementing the StandardInput=, StandardOutput= or StandardError= directives in the service definition. But since the ExecStart is specifically reported to have been PID 4601 and having exited with status=0/SUCCESS, that was not what happened here. The ExecStop was executed as PID 4758, so it's not from that one either.

The status code 202 is from the "main process" of your application (the one that had PID 4747), and it means whatever the application developer wanted it to mean.

The lingering TCP socket is not the cause: since your application process died, the kernel will have cleaned up any lingering sockets it may have had.

Of course, if the application did not use the SO_REUSEADDR socket option, it might not be possible to immediately restart the application and have it use the same port number, until the lingering socket's TIME_WAIT has expired... but that's not systemd's problem; that's something the application will have to deal with on its own.

The /FDS part comes from the exit_status_to_string() function in shared/exit-status.c file in the systemd source code package.

That function is supposed to add a brief hint to what the status code may mean, if the code has any standardized meaning. The function can take a parameter that determines which set(s) of status code hints to use, but when systemctl status uses the function (i.e. in file systemctl/systemctl-show.c, it (as of this writing) seems to always call it with that parameter set to EXIT_STATUS_LIBC | EXIT_STATUS_SYSTEMD, i.e. "show the status code hints according to the usage of libc and systemd itself" without checking if the status code in fact came from a process that was a member of the systemd software suite or not.

The end result is that status 202 always gets /FDS appended to it, whether it's known to have the systemd-specific meaning "Failed to close unwanted file descriptors, or to adjust passed file descriptors" or not. It's just a simple table lookup: don't presume it has any more intelligence than that.

(In Unix programming literature and programmer jargon, "fds" is a pretty universal shorthand for the words "file descriptors". The /FDS also suggests the symbolic name of status code 202 in systemd's code: EXIT_FDS - and since all systemd's status code symbols have the EXIT_ prefix, it's chopped of for brevity.)

  • Thanks! That narrows it down somewhat. I have not found anything about exit codes in the application manual so it seems I have to venture into its source code to find out...
    – Lii
    Commented Jun 15, 2022 at 15:53
  • A follow-up question: The status output doesn't say simply status=202, is says status=202/FDS . Where does FDS comes from? I has to come from systemd, doesn't it? Why does systemd interpret exit code 202 as FDS? What does FDS mean? Where can I find documentation about that?
    – Lii
    Commented Jun 17, 2022 at 19:59
  • Here is some information about the interpretation of status codes by systemd: unix.stackexchange.com/a/458655/31224
    – Lii
    Commented Jun 17, 2022 at 20:04
  • Unfortunately figuring out that detail currently required reading some of the source code of the systemctl command. See my edit above.
    – telcoM
    Commented Jun 17, 2022 at 22:45
  • Great, thanks! That's also what I gathered from the answer I link above. From reading the source code of my application it seems like it returned 202 after failing to rename a journaling file.
    – Lii
    Commented Jun 18, 2022 at 6:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .