MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / lwp_pid2name

Function lwp_pid2name

components/lwp/lwp_pid.c:1079–1094  ·  view source on GitHub ↗

* @brief Convert process ID to process name * * @param[in] pid Process ID to look up * * @return char* Pointer to the process name (without path) if found, or RT_NULL if not found */

Source from the content-addressed store, hash-verified

1077 * @return char* Pointer to the process name (without path) if found, or RT_NULL if not found
1078 */
1079char* lwp_pid2name(int32_t pid)
1080{
1081 struct rt_lwp *lwp;
1082 char* process_name = RT_NULL;
1083
1084 lwp_pid_lock_take();
1085 lwp = lwp_from_pid_locked(pid);
1086 if (lwp)
1087 {
1088 process_name = strrchr(lwp->cmd, '/');
1089 process_name = process_name? process_name + 1: lwp->cmd;
1090 }
1091 lwp_pid_lock_release();
1092
1093 return process_name;
1094}
1095
1096/**
1097 * @brief Convert process name to process ID

Callers

nothing calls this directly

Calls 3

lwp_pid_lock_takeFunction · 0.85
lwp_from_pid_lockedFunction · 0.85
lwp_pid_lock_releaseFunction · 0.85

Tested by

no test coverage detected