Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Language Bindings
  4. Monitoring UNIX File Descriptor for pty.fork() in PyQt4
Forum Updated to NodeBB v4.3 + New Features

Monitoring UNIX File Descriptor for pty.fork() in PyQt4

Scheduled Pinned Locked Moved Language Bindings
1 Posts 1 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    abhijangda
    wrote on last edited by
    #1

    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
    @

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved