Merge pull request #210 from nowaits/master
add clixon proc get pid api
This commit is contained in:
commit
e59b7e1616
2 changed files with 34 additions and 0 deletions
|
|
@ -61,6 +61,7 @@ typedef int (proc_cb_t)(clicon_handle h, process_entry_t *pe, proc_operation *op
|
||||||
int clixon_proc_socket(char **argv, pid_t *pid, int *sock);
|
int clixon_proc_socket(char **argv, pid_t *pid, int *sock);
|
||||||
int clixon_proc_socket_close(pid_t pid, int sock);
|
int clixon_proc_socket_close(pid_t pid, int sock);
|
||||||
int clixon_proc_background(char **argv, const char *netns, pid_t *pid);
|
int clixon_proc_background(char **argv, const char *netns, pid_t *pid);
|
||||||
|
int clixon_process_pid(clicon_handle h, const char *name, pid_t *pid);
|
||||||
proc_operation clixon_process_op_str2int(char *opstr);
|
proc_operation clixon_process_op_str2int(char *opstr);
|
||||||
int clixon_process_argv_get(clicon_handle h, const char *name, char ***argv, int *argc);
|
int clixon_process_argv_get(clicon_handle h, const char *name, char ***argv, int *argc);
|
||||||
int clixon_process_register(clicon_handle h, const char *name, const char *descr, const char *netns, proc_cb_t *callback, char **argv, int argc);
|
int clixon_process_register(clicon_handle h, const char *name, const char *descr, const char *netns, proc_cb_t *callback, char **argv, int argc);
|
||||||
|
|
|
||||||
|
|
@ -540,6 +540,39 @@ proc_op_run(pid_t pid0,
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
clixon_process_pid(clicon_handle h,
|
||||||
|
const char *name,
|
||||||
|
pid_t *pid)
|
||||||
|
{
|
||||||
|
int retval = -1;
|
||||||
|
process_entry_t *pe;
|
||||||
|
int isrunning; /* Process is actually running */
|
||||||
|
|
||||||
|
if (_proc_entry_list == NULL || !pid)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
pe = _proc_entry_list;
|
||||||
|
do {
|
||||||
|
if (strcmp(pe->pe_name, name) == 0) {
|
||||||
|
isrunning = 0;
|
||||||
|
if (proc_op_run(pe->pe_pid, &isrunning) < 0)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
if (!isrunning)
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
*pid = pe->pe_pid;
|
||||||
|
retval = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
pe = NEXTQ(process_entry_t *, pe);
|
||||||
|
} while (pe != _proc_entry_list);
|
||||||
|
|
||||||
|
done:
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
|
||||||
/*! Find process entry given name and schedule operation
|
/*! Find process entry given name and schedule operation
|
||||||
*
|
*
|
||||||
* @param[in] h clicon handle
|
* @param[in] h clicon handle
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue