devsnek / esvu

esvu is your one-stop shop for all implementations of ECMAScript.
MIT License
172 stars 21 forks source link

FYI: When using bash for ~/.esvu/bin/v8 v8/d8 continues to run after parent program exits #58

Open guest271314 opened 1 month ago

guest271314 commented 1 month ago

Re

Some binaries may be exposed as batch/shell scripts to properly handling shared library loading.

When we use this

#!/usr/bin/env -S /home/user/.esvu/bin/v8

as a Native Messaging host called by chrome to launch d8, then terminate all instances of chrome, the script will still be running even after the parent program terminates.

When we use this

#!/usr/bin/env -S /home/user/.jsvu/engines/v8/v8

d8 terminates when the parent program, in this case, chrome, closes.

Not sure if this is known or not that using bash here (which is an alias for dash on my machine) causes this behaviour.

#!/usr/bin/env bash
"/home/user/.esvu/engines/v8/d8" --snapshot_blob="/home/user/.esvu/engines/v8/snapshot_blob.bin" "$@"
devsnek commented 1 month ago

@guest271314 I'm not entirely sure what you're trying to do but it sounds like something that exec might fix:

#!/usr/bin/env bash
exec "/home/user/.esvu/engines/v8/d8" --snapshot_blob="/home/user/.esvu/engines/v8/snapshot_blob.bin" "$@"

If you test this and it works for you, please consider opening a PR.

guest271314 commented 1 month ago

Using exec fixes the issue. Where in esvu source code is the v8 shell script generated?

devsnek commented 1 month ago

https://github.com/devsnek/esvu/blob/09a20f30533dbc4c3f3d6c5165f478fe4c998dff/src/installer.js#L220