-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
fork_test.c
#include <Windows.h>
#include <forklib.h>
#include <stdio.h>
int main() {
HANDLE test_event = CreateEventA(NULL, FALSE, FALSE, "TestEvent");
MarkAllHandlesInheritable();
ForkSettings fork_settings = {true, true};
PROCESS_INFORMATION process_info = {0};
const auto res = Fork(fork_settings, &process_info);
if (res == -1) {
printf("fork failed\n");
return 1;
}
if (res != 0) {
// Parent
printf("forked process's PID is %lu\n", res);
getc(stdin);
if (test_event != NULL) {
printf("Notifying event\n");
SetEvent(test_event);
}
} else {
// Child
printf("Child's alive\n");
if (test_event != NULL) {
printf("Waiting for event to be notified...\n");
WaitForSingleObject(test_event, INFINITE);
printf("Event notified by parent!\n");
}
getc(stdin);
}
}Not Working
>dir
C 드라이브의 볼륨에는 이름이 없습니다.
볼륨 일련 번호: D4A0-49DC
C:\Users\dong\Desktop\forklib\x64\tests\fork_test_c\Release 디렉터리
2023-09-27 오전 10:54 <DIR> .
2023-09-27 오전 10:53 <DIR> ..
2022-05-07 오후 02:19 2,184,528 dbghelp.dll
2023-09-26 오후 11:33 159,744 forklib.dll
2023-09-26 오후 11:33 1,001 forklib.exp
2023-09-26 오후 11:33 2,168 forklib.lib
2023-09-27 오전 10:53 142,848 fork_test_c.exe
2023-09-27 오전 10:54 <DIR> ntdll.dll
2023-09-27 오전 10:54 <DIR> ntdll.pdb
2023-09-26 오후 11:28 256,456 symsrv.dll
6개 파일 2,746,745 바이트
4개 디렉터리 227,914,108,928 바이트 남음
>.\fork_test_c.exe
forked process's PID is 31304
Notifying event
Metadata
Metadata
Assignees
Labels
No labels