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

Function sys_exec

components/lwp/lwp_syscall.c:1310–1339  ·  view source on GitHub ↗

* @brief Replaces the current process with a new process. * * This system call loads a new program into the current process's address space, * replacing the current program with the one specified by `filename`. It passes the * arguments `argv` and environment variables `envp` to the new program. If the execution * is successful, the current process is completely replaced, and no code after th

Source from the content-addressed store, hash-verified

1308 * @see execve(), execvp(), execv(), execle()
1309 */
1310sysret_t sys_exec(char *filename, int argc, char **argv, char **envp)
1311{
1312 int ret = 0;
1313 int len = 0;
1314 char *kfilename = RT_NULL;
1315
1316 len = lwp_user_strlen(filename);
1317 if (len <= 0)
1318 {
1319 return -EFAULT;
1320 }
1321
1322 kfilename = (char *)kmem_get(len + 1);
1323 if (!kfilename)
1324 {
1325 return -ENOMEM;
1326 }
1327
1328 if (lwp_get_from_user(kfilename, (void *)filename, len + 1) != (len + 1))
1329 {
1330 kmem_put(kfilename);
1331 return -EFAULT;
1332 }
1333
1334 ret = lwp_execve(kfilename, 0, argc, argv, envp);
1335
1336 kmem_put(kfilename);
1337
1338 return ret;
1339}
1340
1341/**
1342 * @brief Sends a signal to a process or a group of processes.

Callers

nothing calls this directly

Calls 5

lwp_user_strlenFunction · 0.85
kmem_getFunction · 0.85
lwp_get_from_userFunction · 0.85
kmem_putFunction · 0.85
lwp_execveFunction · 0.85

Tested by

no test coverage detected