From 479ad625551a4244668bf5c9dc275deaa2bc7ee5 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Thu, 10 Apr 2014 13:02:49 -0700 Subject: [PATCH] Prevent setsid() failure from taking down ycmd --- python/ycm/server/ycmd.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/python/ycm/server/ycmd.py b/python/ycm/server/ycmd.py index 7903bba2..34e66172 100755 --- a/python/ycm/server/ycmd.py +++ b/python/ycm/server/ycmd.py @@ -113,7 +113,11 @@ def Main(): # If not on windows, detach from controlling terminal to prevent # SIGINT from killing us. if not utils.OnWindows(): - os.setsid() + try: + os.setsid() + # setsid() can fail if the user started ycmd directly from a shell. + except OSError: + pass # This can't be a top-level import because it transitively imports # ycm_core which we want to be imported ONLY after extra conf