Skip to content

Commit

Permalink
Merge pull request #17 from cgundogan/pr/native/socat
Browse files Browse the repository at this point in the history
use socat to redirect STDIN/OUT of riot's native port
  • Loading branch information
OlegHahm committed Mar 10, 2016
2 parents 95ca056 + cfd1327 commit d830ee7
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions desvirt/riotnative.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,12 @@ def create(self):
port_number = int(self.tcp_port)
else:
port_number = get_free_tcp_port(logger=self.logger)
start_riot = "%s %s -t %d -d" % (self.binary, self.tap, port_number)
start_riot = "socat EXEC:'%s %s',end-close,stderr,pty TCP-L:%d,reuseaddr,fork" \
% (self.binary, self.tap, port_number)
self.logger.info("Start the RIOT: %s" % start_riot)
try:
output = subprocess.check_output(start_riot, shell=True)
re_riot = re.compile("^RIOT pid: (?P<pid>[0-9]+)$")
m = re_riot.match(output)
self.pid = int(m.group('pid'))
proc = subprocess.Popen(start_riot, shell=True)
self.pid = proc.pid
self.logger.info("PID: %d" % self.pid)
except subprocess.CalledProcessError:
self.logger.error("creating RIOT native process failed")
Expand All @@ -58,7 +57,7 @@ def create(self):

def destroy(self):
self.logger.info("Kill the RIOT: %s (%s)" % (self.binary, self.pid))
kill_string = ['kill %d' % self.pid]
kill_string = ['pkill -f -9 "%s %s"' % (self.binary, self.tap)]
if subprocess.call(kill_string, stderr=subprocess.PIPE, shell=True):
self.logger.error("killing RIOT native process failed")
sys.exit(1)
Expand Down

0 comments on commit d830ee7

Please sign in to comment.