mirror of
https://github.com/Fennix-Project/Userspace.git
synced 2025-07-10 14:49:22 +00:00
Update userspace
This commit is contained in:
@ -2,6 +2,12 @@
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc == 1)
|
||||
{
|
||||
printf("Usage: echo [args]\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
printf("%s ", argv[i]);
|
||||
printf("\n");
|
||||
|
@ -28,7 +28,7 @@ endif
|
||||
OBJ = $(C_SOURCES:.c=.o) $(CPP_SOURCES:.cpp=.o) $(ASM_SOURCES:.asm=.o) $(S_SOURCES:.S=.o) $(PSF_SOURCES:.psf=.o) $(BMP_SOURCES:.bmp=.o)
|
||||
|
||||
SYSROOT = --sysroot=$(WORKSPACE)out/
|
||||
FILENAME = fsh
|
||||
FILENAME = sh
|
||||
|
||||
HEADERS = $(sort $(dir $(wildcard $(WORKSPACE)out/include/*)))
|
||||
|
||||
|
@ -39,7 +39,7 @@ CFLAGS = -I$(WORKSPACE)out/include \
|
||||
WARNCFLAG = -Wall -Wextra
|
||||
|
||||
ifneq ($(OSARCH), aarch64)
|
||||
CFLAGS += -fstack-protector-all -fstack-clash-protection
|
||||
# CFLAGS += -fstack-protector-all -fstack-clash-protection
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
@ -52,7 +52,7 @@ build: $(FILENAME)
|
||||
|
||||
$(FILENAME): $(OBJ)
|
||||
$(info Linking $@)
|
||||
$(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -lssp -o $@
|
||||
$(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -o $@
|
||||
|
||||
%.o: %.c $(HEADERS)
|
||||
$(info Compiling $<)
|
||||
|
@ -35,50 +35,61 @@ void test_args(int argc, char *argv[], char *envp[])
|
||||
|
||||
int main(int argc, char *argv[], char *envp[])
|
||||
{
|
||||
freopen("/dev/tty", "w", stdout);
|
||||
freopen("/dev/tty", "w", stderr);
|
||||
|
||||
test_args(argc, argv, envp);
|
||||
FILE *test = fopen("/Test.txt", "r");
|
||||
printf("Hello, World!\n");
|
||||
// while (1);
|
||||
// test_args(argc, argv, envp);
|
||||
FILE *test = fopen("/test.txt", "r");
|
||||
if (test == NULL)
|
||||
{
|
||||
printf("Failed to open file\n");
|
||||
return 1;
|
||||
return -0xF11e;
|
||||
}
|
||||
|
||||
printf("Test.txt contents: ");
|
||||
char ch;
|
||||
do
|
||||
while (1)
|
||||
{
|
||||
ch = fgetc(test);
|
||||
if (ch == EOF)
|
||||
{
|
||||
printf("\n");
|
||||
break;
|
||||
}
|
||||
putchar(ch);
|
||||
} while (ch != EOF);
|
||||
|
||||
}
|
||||
fclose(test);
|
||||
|
||||
pid_t pid;
|
||||
int status;
|
||||
|
||||
pid = fork();
|
||||
pid_t pid = fork();
|
||||
|
||||
if (pid == 0) // Child process
|
||||
{
|
||||
pid_t pid2 = fork();
|
||||
if (pid == 0) // Child process
|
||||
{
|
||||
char *shebang_args[] = {"/test.sh", NULL};
|
||||
execv(shebang_args[0], shebang_args);
|
||||
}
|
||||
|
||||
printf("Creating shell process\n");
|
||||
char *args[] = {"/bin/sh", NULL};
|
||||
char *args[] = {"/bin/echo", "Hello, World!", NULL};
|
||||
execv(args[0], args);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
else if (pid > 0)
|
||||
{
|
||||
printf("Waiting for child process %d to exit\n", pid);
|
||||
int status;
|
||||
wait(&status);
|
||||
if (WIFEXITED(status))
|
||||
int exited = WIFEXITED(status);
|
||||
if (exited)
|
||||
{
|
||||
printf("Child process exited with code: %d\n", WEXITSTATUS(status));
|
||||
return WEXITSTATUS(status);
|
||||
int exit_code = WEXITSTATUS(status);
|
||||
printf("Child process exited with code: %d\n", exit_code);
|
||||
return exit_code;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Execution failed.\n");
|
||||
printf("Execution failed. (%d)\n", exited);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
Submodule apps/user/games/doomgeneric updated: 1a54c1624f...b961b5551b
Reference in New Issue
Block a user