Skip to content

Commit cecdcc6

Browse files
committed
fix agent on Windows
1 parent a2fc0e6 commit cecdcc6

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

agent/src/log.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,22 @@ const fildes: NativePointer = Memory.alloc(SIZEOF_INT * 2);
1010

1111
let stream: UnixInputStream;
1212

13-
const pipe = new NativeFunction(Module.findExportByName(null, 'pipe')!, 'int', ['pointer']);
14-
const dup2 = new NativeFunction(Module.findExportByName(null, 'dup2')!, 'int', ['int', 'int']);
15-
const close = new NativeFunction(Module.findExportByName(null, 'close')!, 'int', ['int']);
16-
const fcntl = new NativeFunction(Module.findExportByName(null, 'fcntl')!, 'int', ['int', 'int', 'int']);
17-
1813
export function start() {
14+
stop();
15+
16+
const resolve = (name: string): NativePointer => {
17+
const p = Module.findExportByName(null, name);
18+
if (!p) {
19+
throw new Error(`Platform not supported. Is your target on ${name}?`);
20+
}
21+
return p;
22+
}
23+
24+
const pipe = new NativeFunction(resolve('pipe'), 'int', ['pointer']);
25+
const dup2 = new NativeFunction(resolve('dup2'), 'int', ['int', 'int']);
26+
const close = new NativeFunction(resolve('close'), 'int', ['int']);
27+
const fcntl = new NativeFunction(resolve('fcntl'), 'int', ['int', 'int', 'int']);
28+
1929
pipe(fildes);
2030

2131
const input = fildes.readInt();

0 commit comments

Comments
 (0)