Esempio n. 1
0
    def evalInput(self, input):
        args = LaunchArguments([self.path], True)
        try:
            manager = ProcessManager(args, None)
        except PtraceError as e:
            warning(e)
            return -1

        def do_write(proc_wrap: ProcessWrapper, s: str):
            if DO_SYSCALL:
                proc_wrap.writeToBuf(
                    'b"""%s"""' %
                    s)  # convert this so that no newline is added
            else:
                proc_wrap.in_pipe.write(s)

        proc_wrap = manager.getCurrentProcess()
        do_write(proc_wrap, input + "\n")

        try:
            manager.cont()
        except KeyboardInterrupt:
            pass

        out = proc_wrap.read(0x1000)
        assert out.startswith(b",") and out.endswith(b".")
        return int(out[1:-1])