runner.py

tcprocd runner.

class tcprocd.runner.Runner(name, command, owner, on_exit, path=None, as_user=None, as_group=None)[source]

Bases: threading.Thread

A class to run a process in a thread.

Parameters:
  • name – name of the process to access it
  • command – command to run the process
  • owner – the user who starts this process
  • on_exit – a function that will be called when the process exits
  • path – Path to execeute the command in
  • user – System user to switch to before starting the process
  • group – System group to switch to before starting the process
daemon = True

Make the thread a daemon

on_line(line)[source]

Send the given line to all attached handlers.

on_exit()[source]

Cleanup and close handlers.

write_line(line)[source]

Write message to process’s stdin.

demote()[source]

Switch user and group.

run()[source]

Start the runner.

Execute command and call on_line for each line of output until it terminates. Change the directory to path and switch user and group (if they’re given) before running the process. Finally call on_exit.

kill()[source]

Kill the process if it exists.