change isShellBuiltin to have each builtin as a different token in a set and lookup cmd to be an element of the set instead of a sequence of characters in a string (tested only on Python 3.6.7). Corrected according to @lantz comments.
This can happen when adjusting a tmux pane running mininet cli. The
process will receive SIGWINCH causing the poll() call to raise
select.error
Below is a session dump with strace
09:55:52.498106 poll([{fd=0, events=POLLIN}, {fd=28, events=POLLIN}], 2, -1) = ? ERESTART_RESTARTBLOCK (Interrupted by signal)
09:55:52.606734 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_KERNEL} ---
09:55:52.606770 rt_sigreturn({mask=[]}) = -1 EINTR (Interrupted system call)
Traceback (most recent call last):
File "examples/topofac.py", line 527, in <module>
run()
File "examples/topofac.py", line 522, in run
CLI( net )
File "/home/yunion/git-repo/mininet/mininet/cli.py", line 68, in __init__
self.run()
File "/home/yunion/git-repo/mininet/mininet/cli.py", line 103, in run
self.cmdloop()
File "/home/yunion/.usr/lib/python2.7/cmd.py", line 142, in cmdloop
stop = self.onecmd(line)
File "/home/yunion/.usr/lib/python2.7/cmd.py", line 220, in onecmd
return self.default(line)
File "/home/yunion/git-repo/mininet/mininet/cli.py", line 422, in default
self.waitForNode( node )
File "/home/yunion/git-repo/mininet/mininet/cli.py", line 440, in waitForNode
bothPoller.poll()
select.error: (4, 'Interrupted system call')
09:55:52.622076 rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7ff9a9b936d0}, {0x7ff9a9ef2230, [], SA_RESTORER, 0x7ff9a9b936d0}, 8) = 0
09:55:52.631905 +++ exited with 1 +++
Previously we looked for 'eth0', but linux has renamed interfaces.
Instead of looking by name, we now look for an interface which
is the appropriate gateway to a remote server address.
fixes#831
The redirection of stderr towards stdout means calls to "which program"
always return something even when "program" is not installed.
This patch checks for the return value instead before returning the
value.
See #814.
pmonitor() is hard to get right, but this seems like
a reasonable improvement:
1. non-blocking I/O so we can drain buffer with impunity
2. drain buffer after poll
3. unregister fd on POLLHUP
Note we may have a unicode splitting problem since we're
decoding chunks of bytes, but that is a problem for another
day I think.
Changes for compatibility with Python 3.
The approach is to make as few changes as possible to maintain compatibility with both Python 2 and Python 3.
We use whatever python is installed, and also support a PYTHON environment variable for installing another version.
For simplicity, we provide mininet.util.pexpect which works out of the box with Python 3 utf-8 strings.
Thanks to @cuihantao for looking at this as well and also for changes to MiniEdit.
Closes#794