syscalls: implement basic execve syscall, no argc, argv, envp support yet

This commit is contained in:
2025-09-14 17:17:42 +03:00
parent 4c26652ee2
commit 91e0379fc9
9 changed files with 192 additions and 38 deletions
+26
View File
@@ -0,0 +1,26 @@
// caller.c
#include <stdio.h>
#include <unistd.h>
int main() {
printf("--- In caller.c ---\n");
printf("This message is from the original program.\n");
printf("Calling execve to run './callee'...\n\n");
// Arguments for the new program
// The first argument is conventionally the program name
char *argv[] = {NULL}; //{ "./callee", "first_arg", "second_arg", NULL };
// Environment variables for the new program
char *envp[] = {NULL}; //{ "CUSTOM_VAR=Hello from caller!", "ANOTHER_VAR=123", NULL };
// The execve system call
// The first argument is the path to the executable
// The second is the array of arguments
// The third is the array of environment variables
execve("callee.", argv, envp);
// This part of the code will only be reached if execve fails
perror("execve failed");
return 1;
}