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));