From: Bruno Haible Date: Tue, 8 Aug 2023 18:27:31 +0000 (+0200) Subject: readutmp: Add comment about multithread-safety. X-Git-Tag: v1.0~951 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=adf1ff12e6f84266c44584e4405fb0c2b391ccb2;p=gnulib.git readutmp: Add comment about multithread-safety. * lib/readutmp.h (read_utmp): Add comment. --- diff --git a/ChangeLog b/ChangeLog index dd730a435f..1697d8a3b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-08-08 Bruno Haible + + readutmp: Add comment about multithread-safety. + * lib/readutmp.h (read_utmp): Add comment. + 2023-08-08 Bruno Haible readutmp: Return entries with unbounded strings on all platforms. diff --git a/lib/readutmp.h b/lib/readutmp.h index 1ddb617b28..9377a1b57f 100644 --- a/lib/readutmp.h +++ b/lib/readutmp.h @@ -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);