jolly has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/43266?usp=email )
Change subject: Add start and stop functions to PIPEasp ......................................................................
Add start and stop functions to PIPEasp
In order to start a process in the background, add a start function that does not wait for the process to terminate. Also add a stop function that kills the process and flushes the receive buffer.
Related: SYS#8101 Change-Id: I5be804e5fa7b9a135cceaf07ac4157895a222b40 --- M library/PIPEasp_Templates.ttcn 1 file changed, 18 insertions(+), 0 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmo-ttcn3-hacks refs/changes/66/43266/1
diff --git a/library/PIPEasp_Templates.ttcn b/library/PIPEasp_Templates.ttcn index 0775a5e..85a8656 100644 --- a/library/PIPEasp_Templates.ttcn +++ b/library/PIPEasp_Templates.ttcn @@ -70,4 +70,22 @@ return f_PIPEasp_exec_sync_PResult(pt, cmdline, tr_PResult(?, ?, rc)); }
+function f_PIPEasp_exec_async_start(PIPEasp_PT pt, + charstring cmdline, + charstring stdin := "") { + pt.send(ts_PExecute(cmdline, stdin)); +} + +function f_PIPEasp_exec_async_stop(PIPEasp_PT pt, + charstring progname) { + timer t_flush := 0.5; + + pt.send(ts_PExecute("pkill -f " & progname, "")) + + t_flush.start; + alt { + [] pt.receive { repeat; } + [] t_flush.timeout { } + } +} }