summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@sun.com>2009-07-28 14:31:52 -0700
committerAlan Coopersmith <alan.coopersmith@sun.com>2009-07-28 14:31:52 -0700
commitcafa4376f4761c2d565b2c1deeb7dbfb553d7045 (patch)
treeff33357314fa5c7ca9f33549b30b82b3ad78f022
parent500775eb145372c5dcbc6e9814858d01730900c7 (diff)
Truncate pid file before writing new pid to it
Prevents trailing garbage in the file if the new pid has fewer digits than the previous pid. (Originally reported against Solaris dtlogin as Sun bug 6627150) Signed-off-by: Alan Coopersmith <alan.coopersmith@sun.com>
-rw-r--r--dm.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/dm.c b/dm.c
index 655380e..c482017 100644
--- a/dm.c
+++ b/dm.c
@@ -910,6 +910,7 @@ StorePid (void)
# endif
#endif
}
+ ftruncate(pidFd, 0);
fprintf (pidFilePtr, "%5ld\n", (long)getpid ());
(void) fflush (pidFilePtr);
RegisterCloseOnFork (pidFd);