Call shell commands
Overview
Routines to call shell commands
Copyright (C) 2004-2022 OKTET Labs Ltd. More…
// global functions pid_t te_shell_cmd(const char* cmd, uid_t uid, int* in_fd, int* out_fd, int* err_fd);
Detailed Documentation
Routines to call shell commands
Copyright (C) 2004-2022 OKTET Labs Ltd. All rights reserved.
Global Functions
pid_t te_shell_cmd(const char* cmd, uid_t uid, int* in_fd, int* out_fd, int* err_fd)
Function to base system()-like and popen()-like functions on it. You MUST use uid parameter instead of “su - user -c”, because su makes one more fork, and you do not know how to kill this grandchild process.
If you use this fuction from agent, this process SHOULD be catched by ta_waitpid() or killed by ta_kill_death().
Parameters:
cmd |
command to run in the shell |
uid |
user id to run the shell; use -1 for default |
in_fd |
location to store file descriptor of pipe to stdin of the shell command; use NULL for standard stdin |
out_fd |
location to store file descriptor of pipe to stdout of the shell command; use NULL for standard stdout |
err_fd |
location to store file descriptor of pipe to stderr of the shell command; use NULL for standard stderr |
Returns:
pid value, positive on success, negative on failure