diff --git a/lib/file_system/backends/fs_inotify.ex b/lib/file_system/backends/fs_inotify.ex index 422119475b9ea7920db2d799c089ad6937989f14..0e0fa1f4f00e2a1429be9d82fe614235656a4ba0 100644 --- a/lib/file_system/backends/fs_inotify.ex +++ b/lib/file_system/backends/fs_inotify.ex @@ -98,16 +98,30 @@ defmodule FileSystem.Backends.FSInotify do def init(args) do {worker_pid, rest} = Keyword.pop(args, :worker_pid) + case parse_options(rest) do {:ok, port_args} -> bash_args = ['-c', '#{executable_path()} $0 $@ & PID=$!; read a; kill -KILL $PID'] + + all_args = + case :os.type() do + {:unix, :freebsd} -> + bash_args ++ ['--'] ++ port_args + + _ -> + bash_args ++ port_args + end + port = Port.open( {:spawn_executable, '/bin/sh'}, - [:stream, :exit_status, {:line, 16384}, {:args, bash_args ++ port_args}, {:cd, System.tmp_dir!()}] + [:stream, :exit_status, {:line, 16384}, {:args, all_args}, {:cd, System.tmp_dir!()}] ) + Process.link(port) Process.flag(:trap_exit, true) + {:ok, %{port: port, worker_pid: worker_pid}} + {:error, _} -> :ignore end