fork return value

This commit is contained in:
2026-02-25 14:44:18 +01:00
parent 8b271e2470
commit b958e9461e
5 changed files with 18 additions and 8 deletions

View File

@@ -45,19 +45,26 @@ extern "C" void main() {
//sys_test(1,2,3,4,5);
fork();
uint8_t ret = fork();
//ret = fork();
unsigned id = sys_getpid();
char text[] = "appX";
text[3] = 0x30+id;
write(1, text, sizeof(text), 0, (int)id);
write(1, text, strlen(text), 0, (int)id);
char msg[] = "forked pid: ";
msg[12] = 0x30+ret;
write(1, msg, strlen(msg), 6, (int)id);
uint8_t cnt = 0;
while(1){
cnt = (cnt+1)%100;
char msg[12];
char* num = itoa(cnt, msg);
write(1, num, strlen(num), 10, (int)id);
write(1, num, strlen(num), 25, (int)id);
sleep(100);
}