Skip to content
Snippets Groups Projects
Commit 47bbb47c authored by Tan Jay Jun's avatar Tan Jay Jun Committed by Xiangrong Hao
Browse files

Kill inotifywait when BEAM process exits and stop leaks (#39)

parent dabda37a
Branches
No related tags found
No related merge requests found
......@@ -106,9 +106,10 @@ defmodule FileSystem.Backends.FSInotify do
{worker_pid, rest} = Keyword.pop(args, :worker_pid)
case parse_options(rest) do
{:ok, port_args} ->
bash_args = ['-c', to_charlist(executable_path()) ++ ' $0 $@ & PID=$!; read a; kill $PID']
port = Port.open(
{:spawn_executable, to_charlist(executable_path())},
[:stream, :exit_status, {:line, 16384}, {:args, port_args}, {:cd, System.tmp_dir!()}]
{:spawn_executable, '/bin/sh'},
[:stream, :exit_status, {:line, 16384}, {:args, bash_args ++ port_args}, {:cd, System.tmp_dir!()}]
)
Process.link(port)
Process.flag(:trap_exit, true)
......
......@@ -24,7 +24,7 @@ defmodule FileSystem.Backends.FSInotifyTest do
assert {:ok, ['-e', 'modify', '-e', 'close_write', '-e', 'moved_to', '-e', 'create', '-e',
'delete', '-e', 'attrib', '--format', [37, 119, 1, 37, 101, 1, 37, 102],
'--quiet', '-m', '/tmp']} ==
parse_options(dirs: ["/tmp"], recursive: false, unsuppported: :options)
parse_options(dirs: ["/tmp"], recursive: false, unsupported: :options)
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment