diff options
author | Lukas Larsson <[email protected]> | 2015-12-10 10:59:34 +0100 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2016-03-29 14:57:10 +0200 |
commit | 348f3f2ee2d2707e30658c3600e05309ad0e72bf (patch) | |
tree | 8557d5468c3a3b68bf55ac586b9c7b322e4f3198 /erts/emulator/test/nif_SUITE_data | |
parent | 4a736966eba5398a22697db6ca67e1e3dd3cd0f2 (diff) | |
download | otp-348f3f2ee2d2707e30658c3600e05309ad0e72bf.tar.gz otp-348f3f2ee2d2707e30658c3600e05309ad0e72bf.tar.bz2 otp-348f3f2ee2d2707e30658c3600e05309ad0e72bf.zip |
erts: Add enif_is_process/port_alive
Diffstat (limited to 'erts/emulator/test/nif_SUITE_data')
-rw-r--r-- | erts/emulator/test/nif_SUITE_data/nif_SUITE.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c index 1960689590..2ce0168788 100644 --- a/erts/emulator/test/nif_SUITE_data/nif_SUITE.c +++ b/erts/emulator/test/nif_SUITE_data/nif_SUITE.c @@ -30,6 +30,7 @@ static int static_cntA; /* zero by default */ static int static_cntB = NIF_SUITE_LIB_VER * 100; static ERL_NIF_TERM atom_false; +static ERL_NIF_TERM atom_true; static ERL_NIF_TERM atom_self; static ERL_NIF_TERM atom_ok; static ERL_NIF_TERM atom_join; @@ -138,6 +139,7 @@ static int load(ErlNifEnv* env, void** priv_data, ERL_NIF_TERM load_info) msgenv_dtor, ERL_NIF_RT_CREATE, NULL); atom_false = enif_make_atom(env,"false"); + atom_true = enif_make_atom(env,"true"); atom_self = enif_make_atom(env,"self"); atom_ok = enif_make_atom(env,"ok"); atom_join = enif_make_atom(env,"join"); @@ -2008,6 +2010,26 @@ static ERL_NIF_TERM unique_integer(ErlNifEnv* env, int argc, const ERL_NIF_TERM return enif_make_unique_integer(env, properties); } +static ERL_NIF_TERM is_process_alive(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) +{ + ErlNifPid pid; + if (!enif_get_local_pid(env, argv[0], &pid)) + return enif_make_badarg(env); + if (enif_is_process_alive(env, &pid)) + return atom_true; + return atom_false; +} + +static ERL_NIF_TERM is_port_alive(ErlNifEnv* env, int argc, const ERL_NIF_TERM argv[]) +{ + ErlNifPort port; + if (!enif_get_local_port(env, argv[0], &port)) + return enif_make_badarg(env); + if (enif_is_port_alive(env, &port)) + return atom_true; + return atom_false; +} + static ErlNifFunc nif_funcs[] = { {"lib_version", 0, lib_version}, @@ -2083,7 +2105,9 @@ static ErlNifFunc nif_funcs[] = {"convert_time_unit", 3, convert_time_unit}, {"now_time", 0, now_time}, {"cpu_time", 0, cpu_time}, - {"unique_integer_nif", 1, unique_integer} + {"unique_integer_nif", 1, unique_integer}, + {"is_process_alive_nif", 1, is_process_alive}, + {"is_port_alive_nif", 1, is_port_alive} }; ERL_NIF_INIT(nif_SUITE,nif_funcs,load,reload,upgrade,unload) |