snsh: Added '-q' to break program to REPL via keyboard #629
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Now you can run any Snabb-based program in a mode that supports
interrupting it with the keyboard (Control-\ i.e. SIGQUIT) such that
it leaves the breathe loop and enters an interactive read-eval-print
loop (REPL). Here you can poke around with arbitrary Lua expressions
and finally return back to the engine by pressing Control-d (EOF).
The
snsh
argument -q (--sigquit-repl) enables a timer callback in theengine that checks if SIGQUIT has been received and starts a
REPL. This can be combined with the -p (--program) argument to run
another program such as packetblaster or snabbnfv.
For example:
snabb snsh -q -p packetblaster replay 64.cap 0000:01:00.0
will run packetblaster but with the hook enabled such that each time
you press Control-\ the process will receive a SIGQUIT and enter the
REPL like this:
Note: SIGQUIT is detected by a hook function running on a timer and so
it is only effective when the engine's breathe loop is running. (The
REPL does not run inside a Unix signal handler -- the signal only sets
a flag saying that it should be started.)