Skip to content

Commit db2bc91

Browse files
committed
Avoid blocking removal of the directory the server started in
1 parent 7ec0201 commit db2bc91

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
- tar.gz release archive.
88

9+
### Changed
10+
11+
- Change working directory to `/` (or `C:\` on Windows) to avoid blocking
12+
removal of the directory the server was started from.
13+
914
## [0.4] - 2026-03-15
1015

1116
### Changed

src/main.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
#include <uv.h>
1111

12+
#ifdef _WIN32
13+
# include <direct.h>
14+
#else
15+
# include <unistd.h>
16+
#endif
17+
1218
#include <cstdlib>
1319
#include <iostream>
1420

@@ -57,6 +63,16 @@ int main()
5763
return 1;
5864
}
5965

66+
#ifdef _WIN32
67+
if (_chdir("C:\\") != 0) {
68+
LOG("Failed to chdir to C:\\");
69+
}
70+
#else
71+
if (chdir("/") != 0) {
72+
LOG("Failed to chdir to /");
73+
}
74+
#endif
75+
6076
int result = uv_run(loop, UV_RUN_DEFAULT);
6177
LOG("Event loop exited with code " + std::to_string(result));
6278

0 commit comments

Comments
 (0)