banan-os/userspace/test/test.cpp

28 lines
410 B
C++
Raw Normal View History

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
2023-05-28 18:08:26 +03:00
#include <unistd.h>
#define ERROR(msg) { perror(msg); return 1; }
#define BUF_SIZE 1024
int main()
{
char* string = (char*)malloc(10);
strcpy(string, "Hello");
2023-05-28 18:08:26 +03:00
printf("forking\n");
2023-05-28 18:08:26 +03:00
pid_t pid = fork();
if (pid == 0)
{
printf("child '%s'\n", string);
2023-05-28 18:08:26 +03:00
return 0;
}
strcpy(string, "World");
printf("parent '%s'\n", string);
return 0;
}