[LTP] [PATCH v3 1/2] doc: Document process_state
Cyril Hrubis
chrubis@suse.cz
Wed Jan 7 12:11:22 CET 2026
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
---
doc/conf.py | 1 +
doc/developers/api_c_tests.rst | 5 ++++
include/tst_process_state.h | 47 +++++++++++++++++++---------------
3 files changed, 33 insertions(+), 20 deletions(-)
diff --git a/doc/conf.py b/doc/conf.py
index b8ec1c31c..5d7362439 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -36,6 +36,7 @@ extlinks = {
'master': (f'{ltp_repo}/blob/master/%s', '%s'),
'shell_lib': (f'{ltp_repo}/blob/master/testcases/lib/%s', '%s'),
'git_man': ('https://git-scm.com/docs/git-%s', 'git %s'),
+ 'man1': ('https://man7.org/linux/man-pages/man1/%s.1.html', '%s(1)'),
'man2': ('https://man7.org/linux/man-pages/man2/%s.2.html', '%s(2)'),
'man3': ('https://man7.org/linux/man-pages/man3/%s.3.html', '%s(3)'),
# TODO: allow 2nd parameter to show page description instead of plain URL
diff --git a/doc/developers/api_c_tests.rst b/doc/developers/api_c_tests.rst
index 2ca0f0464..13fc8651b 100644
--- a/doc/developers/api_c_tests.rst
+++ b/doc/developers/api_c_tests.rst
@@ -43,6 +43,11 @@ Kernel
.. kernel-doc:: ../../include/tst_kernel.h
.. kernel-doc:: ../../include/tst_kvercmp.h
+Process state
+-------------
+
+.. kernel-doc:: ../../include/tst_process_state.h
+
NUMA
----
.. kernel-doc:: ../../include/tst_numa.h
diff --git a/include/tst_process_state.h b/include/tst_process_state.h
index b1d83e109..fd94ee207 100644
--- a/include/tst_process_state.h
+++ b/include/tst_process_state.h
@@ -15,39 +15,46 @@
#ifdef TST_TEST_H__
-/*
- * Waits for process state change.
+/**
+ * TST_PROCESS_STATE_WAIT() - Waits for a process state change.
+ *
+ * Polls `/proc/$PID/state` for a process state changes.
*
- * The state is one of the following:
+ * @pid: A process pid.
+ * @state: A state to wait for.
+ * @msec_timeout: A timeout for the wait.
*
- * R - process is running
- * S - process is sleeping
- * D - process sleeping uninterruptibly
- * Z - zombie process
- * T - process is traced
+ * Possible process states (see :man1:`ps`):
+ *
+ * - **R** Process is running.
+ * - **S** Process is sleeping.
+ * - **D** Process sleeping uninterruptibly.
+ * - **Z** Zombie process.
+ * - **T** Process is traced.
+ * - **t** Tracing stopped.
+ * - **X** Process id dead.
*/
#define TST_PROCESS_STATE_WAIT(pid, state, msec_timeout) \
tst_process_state_wait(__FILE__, __LINE__, NULL, \
(pid), (state), (msec_timeout))
-/*
- * Check that a given pid is present on the system
+/**
+ * TST_PROCESS_EXIT_WAIT() - Waits while pid is present on the system.
+ *
+ * Loops until `kill($PID, 0)` succeds or timeout is reached.
+ *
+ * @pid A process pid.
+ * @msec_timeout: A timeout for the wait.
*/
#define TST_PROCESS_EXIT_WAIT(pid, msec_timeout) \
tst_process_exit_wait((pid), (msec_timeout))
-/*
- * Waits for thread state change.
+/**
+ * TST_THREAD_STATE_WAIT() - Waits for a thread state change.
*
- * The state is one of the following:
+ * Polls `/proc/self/task/$TID/state` for a thread state change.
*
- * R - running
- * S - sleeping
- * D - disk sleep
- * T - stopped
- * t - tracing stopped
- * Z - zombie
- * X - dead
+ * Possible thread states are the same as for TST_PROCESS_STATE_WAIT().
*/
#define TST_THREAD_STATE_WAIT(tid, state, msec_timeout) \
tst_thread_state_wait((tid), (state), (msec_timeout))
--
2.52.0
More information about the ltp
mailing list