From bc600adbd8c290c9bbfa3cf6e37d5b76ad603287 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Fri, 7 Apr 2017 18:01:14 +0200 Subject: [PATCH] launch_daemon: Don't allow restarting. * Check if the port already exists on startup. This fixes #12901. --- src/servers/launch/LaunchDaemon.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/servers/launch/LaunchDaemon.cpp b/src/servers/launch/LaunchDaemon.cpp index 736b4715b8..1d9b76da0f 100644 --- a/src/servers/launch/LaunchDaemon.cpp +++ b/src/servers/launch/LaunchDaemon.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2015-2016, Axel Dörfler, axeld@pinc-software.de. + * Copyright 2015-2017, Axel Dörfler, axeld@pinc-software.de. * Distributed under the terms of the MIT License. */ @@ -1942,6 +1942,11 @@ open_stdio(int targetFD, int openMode) int main() { + if (find_port(B_LAUNCH_DAEMON_PORT_NAME) >= 0) { + fprintf(stderr, "The launch_daemon is already running!\n"); + return EXIT_FAILURE; + } + // Make stdin/out/err available open_stdio(STDIN_FILENO, O_RDONLY); open_stdio(STDOUT_FILENO, O_WRONLY);