]> Savannah Git Hosting - gnulib.git/commitdiff
readutmp: Add comment about multithread-safety.
authorBruno Haible <bruno@clisp.org>
Tue, 8 Aug 2023 18:27:31 +0000 (20:27 +0200)
committerBruno Haible <bruno@clisp.org>
Tue, 8 Aug 2023 18:27:31 +0000 (20:27 +0200)
* lib/readutmp.h (read_utmp): Add comment.

ChangeLog
lib/readutmp.h

index dd730a435fe9c1a41a57cc3a2c3a36f32061cf27..1697d8a3b940b4029fd610a8b2f3b52dd52dda94 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2023-08-08  Bruno Haible  <bruno@clisp.org>
+
+       readutmp: Add comment about multithread-safety.
+       * lib/readutmp.h (read_utmp): Add comment.
+
 2023-08-08  Bruno Haible  <bruno@clisp.org>
 
        readutmp: Return entries with unbounded strings on all platforms.
index 1ddb617b281b66c1da8a281fa8432099c08cf207..9377a1b57f3857008ba1b7b5bf2e897bee63379d 100644 (file)
@@ -255,7 +255,13 @@ char *extract_trimmed_name (const STRUCT_UTMP *ut)
    If OPTIONS & READ_UTMP_CHECK_PIDS is nonzero, omit entries whose
    process-IDs do not currently exist.
    If OPTIONS & READ_UTMP_USER_PROCESS is nonzero, omit entries which
-   do not correspond to a user process.  */
+   do not correspond to a user process.
+
+   This function is not multithread-safe, since on many platforms it
+   invokes the functions setutxent, getutxent, endutxent.  These
+   functions are needed because they may lock FILE (so that we don't
+   read garbage when a concurrent process writes to FILE), but their
+   drawback is that they have a common global state.  */
 int read_utmp (char const *file, idx_t *n_entries, STRUCT_UTMP **utmp_buf,
                int options);