From 26b527f1516569db5596d0e427629149acce737d Mon Sep 17 00:00:00 2001 From: James Turner Date: Fri, 20 Mar 2020 11:40:32 -0700 Subject: [PATCH] Fix Linux compilation --- src/Main/fg_init.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Main/fg_init.cxx b/src/Main/fg_init.cxx index 3e3b170f3..f01234535 100644 --- a/src/Main/fg_init.cxx +++ b/src/Main/fg_init.cxx @@ -40,6 +40,7 @@ # include # include # include +# include #endif #include @@ -513,9 +514,14 @@ bool fgInitHome() return false; } - write(fd, buf, len); - - int err = flock(fd, LOCK_EX); + int err = write(fd, buf, len); + if (err != 0) { + SG_LOG(SG_GENERAL, SG_ALERT, "failed to write to lock file:" << pidPath + << "\n\tdue to:" << simgear::strutils::error_string(errno)); + return false; + } + + err = flock(fd, LOCK_EX); if (err != 0) { SG_LOG(SG_GENERAL, SG_ALERT, "failed to lock file:" << pidPath << "\n\tdue to:" << simgear::strutils::error_string(errno));