Permalink
Browse files

Set timeout based on OS

On Linux, a timeout of 0 will block until the next packet is received.

On BSD/Mac OS X, 0 will block until the snaplen buffer is full, so set
the default timeout to 500 ms.
  • Loading branch information...
1 parent f0c59d6 commit 2865c2e4fff2ca43ca3b7bd2ac3210a30c33100b @msantos committed Apr 11, 2012
Showing with 5 additions and 1 deletion.
  1. +5 −1 src/epcap.erl
View
@@ -62,7 +62,11 @@ start_link(Pid, Options) ->
init([Pid, Options]) ->
process_flag(trap_exit, true),
Chroot = chroot_path(),
- Cmd = make_args(Options ++ [{chroot, Chroot}]),
+ Timeout = case os:type() of
+ {unix, linux} -> 0;
+ _ -> 500
+ end,
+ Cmd = make_args(Options ++ [{chroot, Chroot}, {timeout, Timeout}]),
Port = open_port({spawn, Cmd}, [{packet, 2}, binary, exit_status]),
{ok, #state{
pid = Pid,

0 comments on commit 2865c2e

Please sign in to comment.