25 lines
714 B
C
25 lines
714 B
C
#include "../include/exectd.h"
|
|
int main() {
|
|
|
|
// 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 fd = ext_open("tests/bin/stdout_dup", O_WRONLY | O_CREAT);
|
|
int fd2 = ext_open("tests/bin/stderr_dup", O_WRONLY | O_CREAT);
|
|
int status = shell_job("/bin/ls", argv, envp, fd, fd2);
|
|
if (status != 0) {
|
|
// Handle error
|
|
printf("Shell job returned error code: %d\n", status);
|
|
}
|
|
|
|
// Code here will run after the child process has finished
|
|
return 0;
|
|
}
|