Catching a direct redirect to /dev/tty

后端 未结 4 2064
抹茶落季
抹茶落季 2021-01-05 23:29

I\'m working on an application controller for a program that is spitting text directly to /dev/tty.

This is a production application controller that must be able to

4条回答
  •  囚心锁ツ
    2021-01-06 00:08

    This is what I did in python

    import pty, os
    
    pid, fd = pty.fork()
    if pid == 0: # In the child process execute another command
        os.execv('./my-progr', [''])
        print "Execv never returns :-)"
    else:
        while True:
            try:
                print os.read(fd,65536),
            except OSError:
                break
    

提交回复
热议问题