Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

snsh: Added '-q' to break program to REPL via keyboard #629

Merged
merged 2 commits into from
Oct 5, 2015

Conversation

lukego
Copy link
Member

@lukego lukego commented Sep 28, 2015

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 the
engine 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:

0000:01:00.1    TXDGPC (TX packets)     13,154,784      GOTCL (TX octets)       894,522,388
^\[snsh: SIGQUIT caught - entering REPL]
Snabb>

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.)

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 argument -q (--sigquit-repl) enables a timer callback in the
engine 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:

    0000:01:00.1    TXDGPC (TX packets)     13,154,784      GOTCL (TX octets)       894,522,388
    ^\[snsh: SIGQUIT caught - entering REPL]
    Snabb>

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.)
Use a command-line syntax that supports saying what should happen when
SIGQUIT is received. This is for future extensibility if we want to do
something else than enter the REPL e.g. toggle debug printouts, enter
a debugger, fork a child for offline debugging, etc.
lukego added a commit to lukego/snabb that referenced this pull request Oct 1, 2015
@eugeneia eugeneia merged commit f87990e into snabbco:master Oct 5, 2015
dpino pushed a commit to dpino/snabb that referenced this pull request Dec 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants