diff options
author | Dmytro Lytovchenko <[email protected]> | 2016-05-25 14:37:03 +0200 |
---|---|---|
committer | Lukas Larsson <[email protected]> | 2016-06-10 09:46:33 +0200 |
commit | 3ee5343415d6ae0ce1ff1c2a2555051431a9315e (patch) | |
tree | 50f0acc46c6f30bf9ce58b9851ca1a2cd92f1772 /erts/emulator/test/port_SUITE_data/sleep_failure_drv.c | |
parent | d26c15e07229c90ba8353bd78d5406ada0f13271 (diff) | |
download | otp-3ee5343415d6ae0ce1ff1c2a2555051431a9315e.tar.gz otp-3ee5343415d6ae0ce1ff1c2a2555051431a9315e.tar.bz2 otp-3ee5343415d6ae0ce1ff1c2a2555051431a9315e.zip |
erts: Add port monitors
* erlang:monitor/2 with port argument is added, erlang:demonitor, using port task API and avoiding locking;
* port_info and process_info support for monitored ports (with named port monitors support);
* Exit signals contain type 'process' or 'port';
* Propagation of port exit signals;
* Self-cleaning when origin process dies with monitor on;
* 8 test cases + testcase for port driver crashing;
* Documentation for all of the above (monitor, demonitor, port_info and process_info) updated
Diffstat (limited to 'erts/emulator/test/port_SUITE_data/sleep_failure_drv.c')
-rw-r--r-- | erts/emulator/test/port_SUITE_data/sleep_failure_drv.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/erts/emulator/test/port_SUITE_data/sleep_failure_drv.c b/erts/emulator/test/port_SUITE_data/sleep_failure_drv.c new file mode 100644 index 0000000000..1f52646572 --- /dev/null +++ b/erts/emulator/test/port_SUITE_data/sleep_failure_drv.c @@ -0,0 +1,76 @@ +#include <stdio.h> +#include "erl_driver.h" +#ifdef __WIN32__ +# include <windows.h> +#else +# include <unistd.h> +#endif + +typedef struct _erl_drv_data FailureDrvData; + +static FailureDrvData *failure_drv_start(ErlDrvPort, char *); +static void failure_drv_stop(FailureDrvData *); +static void failure_drv_output(ErlDrvData, char *, ErlDrvSizeT); +static void failure_drv_finish(void); + +static ErlDrvEntry failure_drv_entry = { + NULL, /* init */ + failure_drv_start, + failure_drv_stop, + failure_drv_output, + NULL, /* ready_input */ + NULL, /* ready_output */ + "sleep_failure_drv", + NULL, /* finish */ + NULL, /* handle */ + NULL, /* control */ + NULL, /* timeout */ + NULL, /* outputv */ + NULL, /* ready_async */ + NULL, + NULL, + NULL, + ERL_DRV_EXTENDED_MARKER, + ERL_DRV_EXTENDED_MAJOR_VERSION, + ERL_DRV_EXTENDED_MINOR_VERSION, + 0, + NULL, + NULL, + NULL, +}; + + + +/* ------------------------------------------------------------------------- +** Entry functions +**/ + +DRIVER_INIT(failure_drv) +{ + return &failure_drv_entry; +} + +static FailureDrvData *failure_drv_start(ErlDrvPort port, char *command) { + void *void_ptr; + + return void_ptr = port; +} + +static void failure_drv_stop(FailureDrvData *data_p) { +} + +static void failure_drv_output(ErlDrvData drv_data, char *buf, ErlDrvSizeT len) { + FailureDrvData *data_p = (FailureDrvData *) drv_data; + void *void_ptr; + ErlDrvPort port = void_ptr = data_p; + +#ifdef __WIN32__ + Sleep(3000); +#else + sleep(3); +#endif + driver_failure(port, 0); +} + +static void failure_drv_finish() { +} |