mirror of https://github.com/garabik/grc.git
testing pseudoterminal
This commit is contained in:
parent
71c6c70965
commit
6b15eede1b
15
grc
15
grc
|
@ -1,6 +1,6 @@
|
|||
#! /usr/bin/env python
|
||||
|
||||
import os, re, string, sys, getopt, signal
|
||||
import os, re, string, sys, getopt, signal, pty
|
||||
|
||||
def version():
|
||||
print ("Generic Colouriser 1.9.1rc1")
|
||||
|
@ -46,8 +46,10 @@ colour = 1
|
|||
|
||||
for i in optlist:
|
||||
if i[0] in ["--stderr", "-e"]:
|
||||
# redirect stderr
|
||||
stderrf = 1
|
||||
elif i[0] in ["--stdout", "-s"]:
|
||||
# redirect stdout
|
||||
stdoutf = 1
|
||||
elif i[0] in ["--config", "-c"]:
|
||||
cfile = i[1]
|
||||
|
@ -106,6 +108,7 @@ if cfile != "" and colour:
|
|||
pidp = os.fork()
|
||||
if pidp == 0: # child
|
||||
if stdoutff:
|
||||
# connect child (this) stdout to pipe write end
|
||||
os.dup2(chio, 1)
|
||||
os.close(choo)
|
||||
os.close(chio)
|
||||
|
@ -113,12 +116,14 @@ if cfile != "" and colour:
|
|||
os.dup2(chie, 2)
|
||||
os.close(choe)
|
||||
os.close(chie)
|
||||
os.execvp(args[0], args)
|
||||
|
||||
#os.execvp(args[0], args)
|
||||
pty.spawn(args)
|
||||
sys.exit(0)
|
||||
|
||||
if stdoutff:
|
||||
pido = os.fork()
|
||||
if pido == 0: # child
|
||||
if pido == 0: # child (grcat)
|
||||
# connect grcat's stdin to pipe read end
|
||||
os.dup2(choo, 0)
|
||||
os.close(choo)
|
||||
os.close(chio)
|
||||
|
@ -155,7 +160,7 @@ if cfile != "" and colour:
|
|||
sys.exit(status and os.WEXITSTATUS(status))
|
||||
|
||||
else:
|
||||
pidp = os.fork()
|
||||
pidp = os.fork()
|
||||
if pidp == 0:
|
||||
os.execvp(args[0], args)
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue