mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-10-19 22:21:35 +00:00
munet: import 0.12.15
Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
parent
449e25552b
commit
c510a9e451
@ -24,8 +24,17 @@ import tempfile
|
|||||||
import termios
|
import termios
|
||||||
import tty
|
import tty
|
||||||
|
|
||||||
from . import linux
|
|
||||||
from .config import list_to_dict_with_key
|
try:
|
||||||
|
from . import linux
|
||||||
|
from .config import list_to_dict_with_key
|
||||||
|
except ImportError:
|
||||||
|
# We cannot use relative imports and still run this module directly as a script, and
|
||||||
|
# there are some use cases where we want to run this file as a script.
|
||||||
|
sys.path.append(os.path.dirname(os.path.realpath(__file__)))
|
||||||
|
import linux
|
||||||
|
|
||||||
|
from config import list_to_dict_with_key
|
||||||
|
|
||||||
|
|
||||||
ENDMARKER = b"\x00END\x00"
|
ENDMARKER = b"\x00END\x00"
|
||||||
@ -609,7 +618,16 @@ async def doline(
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
await run_command(
|
await run_command(
|
||||||
unet, outf, nline, execfmt, banner, hosts, toplevel, kinds, ns_only, interactive
|
unet,
|
||||||
|
outf,
|
||||||
|
nline,
|
||||||
|
execfmt,
|
||||||
|
banner,
|
||||||
|
hosts,
|
||||||
|
toplevel,
|
||||||
|
kinds,
|
||||||
|
ns_only,
|
||||||
|
interactive,
|
||||||
)
|
)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
@ -657,10 +675,10 @@ async def cli_client(sockpath, prompt="munet> "):
|
|||||||
|
|
||||||
async def local_cli(unet, outf, prompt, histfile, background):
|
async def local_cli(unet, outf, prompt, histfile, background):
|
||||||
"""Implement the user-side CLI for local munet."""
|
"""Implement the user-side CLI for local munet."""
|
||||||
if unet:
|
assert unet is not None
|
||||||
completer = Completer(unet)
|
completer = Completer(unet)
|
||||||
readline.parse_and_bind("tab: complete")
|
readline.parse_and_bind("tab: complete")
|
||||||
readline.set_completer(completer.complete)
|
readline.set_completer(completer.complete)
|
||||||
|
|
||||||
print("\n--- Munet CLI Starting ---\n\n")
|
print("\n--- Munet CLI Starting ---\n\n")
|
||||||
while True:
|
while True:
|
||||||
@ -669,8 +687,6 @@ async def local_cli(unet, outf, prompt, histfile, background):
|
|||||||
if line is None:
|
if line is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
assert unet is not None
|
|
||||||
|
|
||||||
if not await doline(unet, line, outf, background):
|
if not await doline(unet, line, outf, background):
|
||||||
return
|
return
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
@ -706,10 +722,19 @@ async def cli_client_connected(unet, background, reader, writer):
|
|||||||
break
|
break
|
||||||
line = line.decode("utf-8").strip()
|
line = line.decode("utf-8").strip()
|
||||||
|
|
||||||
# def writef(x):
|
class EncodingFile:
|
||||||
# writer.write(x.encode("utf-8"))
|
"""Wrap a writer to encode in utf-8."""
|
||||||
|
|
||||||
if not await doline(unet, line, writer, background, notty=True):
|
def __init__(self, writer):
|
||||||
|
self.writer = writer
|
||||||
|
|
||||||
|
def write(self, x):
|
||||||
|
self.writer.write(x.encode("utf-8"))
|
||||||
|
|
||||||
|
def flush(self):
|
||||||
|
self.writer.flush()
|
||||||
|
|
||||||
|
if not await doline(unet, line, EncodingFile(writer), background, notty=True):
|
||||||
logging.debug("server closing cli connection")
|
logging.debug("server closing cli connection")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -296,8 +296,12 @@ def be_init(new_pg, exec_args):
|
|||||||
# No exec so we are the "child".
|
# No exec so we are the "child".
|
||||||
new_process_group()
|
new_process_group()
|
||||||
|
|
||||||
|
# Reap children as init process
|
||||||
|
vdebug("installing local handler for SIGCHLD")
|
||||||
|
signal.signal(signal.SIGCHLD, sig_sigchld)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
logging.info("parent: waiting to reap zombies")
|
logging.info("init: waiting to reap zombies")
|
||||||
linux.pause()
|
linux.pause()
|
||||||
# NOTREACHED
|
# NOTREACHED
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user