[LTP] [PATCH 2/3] include: Add SAFE_CMD() programming doc

Petr Vorel pvorel@suse.cz
Fri Nov 3 13:34:26 CET 2023


Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 include/tst_safe_macros.h | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/tst_safe_macros.h b/include/tst_safe_macros.h
index 0cf3d7878..6f3289944 100644
--- a/include/tst_safe_macros.h
+++ b/include/tst_safe_macros.h
@@ -646,9 +646,20 @@ int safe_unshare(const char *file, const int lineno, int flags);
 int safe_setns(const char *file, const int lineno, int fd, int nstype);
 #define SAFE_SETNS(fd, nstype) safe_setns(__FILE__, __LINE__, (fd), (nstype))
 
+/*
+ * SAFE_CMD() is a wrapper for tst_cmd(). It runs a command passed via argv[]
+ * and handles non-zero exit (exits with 'TBROK') and 'ENOENT' (the program not
+ * in '$PATH', exits with 'TCONF').
+ *
+ * @param argv[] a 'NULL' terminated array of strings starting with the program
+ * name which is followed by optional arguments.
+ * @param stdout_path: path where to redirect stdout. Set NULL if redirection is
+ * not needed.
+ * @param stderr_path: path where to redirect stderr. Set NULL if redirection is
+ * not needed.
+ */
 void safe_cmd(const char *file, const int lineno, const char *const argv[],
 	const char *stdout_path, const char *stderr_path);
-
 #define SAFE_CMD(argv, stdout_path, stderr_path) \
 	safe_cmd(__FILE__, __LINE__, (argv), (stdout_path), (stderr_path))
 /*
-- 
2.42.0



More information about the ltp mailing list