Re: [LTP] [PATCH v3 1/2] Add tst_gettid wrapper around gettid syscall

Cyril Hrubis
2023-11-01T12:29:16Z

Hi!
> Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.com>
> ---
> include/tst_pid.h | 8 ++++++++
> lib/tst_pid.c | 5 +++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/include/tst_pid.h b/include/tst_pid.h
> index 774c845ce..6958d5d23 100644
> --- a/include/tst_pid.h
> +++ b/include/tst_pid.h
> @@ -50,4 +50,12 @@ static inline int tst_get_free_pids(void (*cleanup_fn)(void))
> */
> pid_t tst_getpid(void);
>
> +/*
> + * Direct gettid() syscall. Some glibc versions cache gettid() return value
> + * which can cause confusing issues for example in processes created by
> + * direct clone() syscall (without using the glibc wrapper). Use this function
> + * whenever the current process may be a child of the main test process.
^
thread spawned from the main ...
> + */
> +pid_t tst_gettid(void);
> +
> #endif /* TST_PID_H__ */
> diff --git a/lib/tst_pid.c b/lib/tst_pid.c
> index cfaa5db36..4e9dc7a52 100644
> --- a/lib/tst_pid.c
> +++ b/lib/tst_pid.c
> @@ -166,3 +166,8 @@ pid_t tst_getpid(void)
> {
> return syscall(SYS_getpid);
> }
> +
> +pid_t tst_gettid(void)
> +{
> + return syscall(SYS_gettid);
> +}
> --
> 2.35.3
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp

--
Cyril Hrubis
chrubis@suse.cz