* lib/sethostname.c (sethostname): Pass an 'e' flag to fopen.
* modules/sethostname (Depends-on): Add fopen-gnu.
+2020-05-27 Bruno Haible <bruno@clisp.org>
+
+ sethostname: Make more robust in multithreaded applications.
+ * lib/sethostname.c (sethostname): Pass an 'e' flag to fopen.
+ * modules/sethostname (Depends-on): Add fopen-gnu.
+
2020-05-27 Bruno Haible <bruno@clisp.org>
readutmp: Make more robust in multithreaded applications.
these are appropriate for us to set, even if they may match the
situation, during failed open/write/close operations, so we
leave errno alone and rely on what the system sets up. */
- hostf = fopen ("/etc/hostname.file", "w");
+ hostf = fopen ("/etc/hostname.file", "we");
if (hostf == NULL)
r = -1;
else
Depends-on:
unistd
errno [test $HAVE_SETHOSTNAME = 0]
+fopen-gnu [test $HAVE_SETHOSTNAME = 0]
configure.ac:
gl_FUNC_SETHOSTNAME