mirror of
https://github.com/uselessd/alcove.git
synced 2026-04-15 01:04:41 +00:00
alcove_drv: add start_link/0,1
Export start_link/0,1. start/0,1 is no longer an alias for start_link and is mainly useful for testing.
This commit is contained in:
@@ -304,6 +304,8 @@ alcove_drv
|
||||
|
||||
start() -> port()
|
||||
start(Options) -> port()
|
||||
start_link() -> port()
|
||||
start_link(Options) -> port()
|
||||
|
||||
Types Options = [Option]
|
||||
Option = stderr_to_stdout | {env, [{Key, Val}]}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
]).
|
||||
|
||||
start() ->
|
||||
alcove_drv:start([{exec, "sudo"}]).
|
||||
alcove_drv:start_link([{exec, "sudo"}]).
|
||||
|
||||
sandbox(Drv) ->
|
||||
sandbox(Drv, ["/bin/busybox", "cat"]).
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
start(GPIO) ->
|
||||
start(GPIO, 1000).
|
||||
start(GPIO, N) ->
|
||||
{ok, Drv} = alcove_drv:start([{exec, "sudo"}]),
|
||||
{ok, Drv} = alcove_drv:start_link([{exec, "sudo"}]),
|
||||
|
||||
export(Drv, GPIO),
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
]).
|
||||
|
||||
start() ->
|
||||
{ok, Drv} = alcove_drv:start([{exec, "sudo"}]),
|
||||
{ok, Drv} = alcove_drv:start_link([{exec, "sudo"}]),
|
||||
case alcove_cgroup:supported(Drv) of
|
||||
true ->
|
||||
ok = alcove_cgroup:create(Drv, [], [<<"alcove">>]),
|
||||
|
||||
@@ -20,7 +20,7 @@ start() ->
|
||||
start([]).
|
||||
|
||||
start(Options) ->
|
||||
{ok, Drv} = alcove_drv:start(Options ++ [{exec, "sudo"}]),
|
||||
{ok, Drv} = alcove_drv:start_link(Options ++ [{exec, "sudo"}]),
|
||||
|
||||
ok = alcove:chdir(Drv, "/"),
|
||||
chroot_init(),
|
||||
|
||||
@@ -41,7 +41,7 @@ accept(LSock, Options) ->
|
||||
accept(LSock, Options).
|
||||
|
||||
create(Socket, _Options) ->
|
||||
{ok, Drv} = alcove_drv:start([{exec,"sudo"}]),
|
||||
{ok, Drv} = alcove_drv:start_link([{exec,"sudo"}]),
|
||||
|
||||
ok = alcove:chdir(Drv, "/"),
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
-include_lib("alcove/include/alcove.hrl").
|
||||
|
||||
%% API
|
||||
-export([start/0, start/1, stop/1]).
|
||||
-export([start_link/2]).
|
||||
-export([start/0, start/1, start/2, stop/1]).
|
||||
-export([start_link/0, start_link/1, start_link/2]).
|
||||
-export([call/5]).
|
||||
-export([stdin/3, stdout/3, stderr/3, event/3, send/3]).
|
||||
-export([getopts/1]).
|
||||
@@ -38,10 +38,22 @@
|
||||
|
||||
-spec start() -> {ok, ref()}.
|
||||
start() ->
|
||||
start_link(self(), []).
|
||||
start(self(), []).
|
||||
|
||||
-spec start(proplists:proplist()) -> {ok, ref()}.
|
||||
start(Options) ->
|
||||
start(self(), Options).
|
||||
|
||||
-spec start(pid(), proplists:proplist()) -> {ok, ref()}.
|
||||
start(Owner, Options) ->
|
||||
gen_server:start(?MODULE, [Owner, Options], []).
|
||||
|
||||
-spec start_link() -> {ok, ref()}.
|
||||
start_link() ->
|
||||
start_link(self(), []).
|
||||
|
||||
-spec start_link(proplists:proplist()) -> {ok, ref()}.
|
||||
start_link(Options) ->
|
||||
start_link(self(), Options).
|
||||
|
||||
-spec start_link(pid(), proplists:proplist()) -> {ok, ref()}.
|
||||
|
||||
@@ -47,7 +47,7 @@ start() ->
|
||||
Env -> Env
|
||||
end,
|
||||
|
||||
{ok, Drv} = alcove_drv:start([
|
||||
{ok, Drv} = alcove_drv:start_link([
|
||||
{exec, Exec},
|
||||
{maxchild, 8},
|
||||
termsig
|
||||
|
||||
@@ -80,7 +80,7 @@ start() ->
|
||||
Exec = getenv("ALCOVE_TEST_EXEC", "sudo"),
|
||||
Use_fork = false =/= getenv("ALCOVE_TEST_USE_FORK", false),
|
||||
|
||||
{ok, Drv} = alcove_drv:start([{exec, Exec}, {maxchild, 8}]),
|
||||
{ok, Drv} = alcove_drv:start_link([{exec, Exec}, {maxchild, 8}]),
|
||||
|
||||
ok = alcove:sigaction(Drv, sigchld, sig_catch),
|
||||
ok = alcove:sigaction(Drv, sigpipe, sig_ign),
|
||||
|
||||
Reference in New Issue
Block a user