* @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
| 1308 | * @see execve(), execvp(), execv(), execle() |
| 1309 | */ |
| 1310 | sysret_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. |
nothing calls this directly
no test coverage detected