Monitoring UNIX File Descriptor for pty.fork() in PyQt4
-
Hello everyone, I'm trying to create a terminal for my application, in Python and PyQt. For this, I'm using psuedo terminal module in Python. pty.fork() returns a file descriptor to the child for reading and writing. So, is there any way I could monitor, the file descriptor for reading in PyQt. I've tried with QSocketNotifier, but nothing happened, i.e. the activated signal is not emmitted even though there is data available for reading.
@class shell(QtGui.QMainWindow):
def __init__(self,parent=None): return_val = pty.fork() if return_val[0] == 0: os.execv("/usr/bin/bash",["/usr/bin/bash"]) else: if return_val[0] >0: self.term_fd = QtCore.QSocketNotifier(return_val[1],QtCore.QSocketNotifier.Read) self.term_fd.setEnabled(True) self.connect(self.term_fd,QtCore.SIGNAL('activated()'),self.processread) #print self.term_fd.readAll() #self.term_fd.write("dir\n") else: print "ERROR" QtGui.QMainWindow.__init__(self,parent) ## ............... other stuff here def processread(self): print 'reading'
##other stuff here
@