exectd/tests/02_execute.c

21 lines
561 B
C
Raw Normal View History

2024-11-16 01:41:47 +00:00
#include "../include/exectd.h"
int main() {
2024-11-23 15:46:38 +00:00
// Arguments for the ls command
char *argv[] = {"ls", "-l", "-a", NULL};
// Custom environment variables
char *envp[] = {
"MY_ENV_VAR=example",
"PATH=/usr/bin:/bin", // Ensure PATH is set for executable lookup
NULL
};
int status = execute_job("/bin/ls", argv, envp);
2024-11-16 01:41:47 +00:00
if (status != 0) {
// Handle error
printf("my_execve returned error code: %d\n", status);
}
// Code here will run after the child process has finished
return 0;
}