popen in thread on QNX

  • Thread starter =?ISO-8859-2?Q?Jacek_Pop=B3awski?=
  • Start date
?

=?ISO-8859-2?Q?Jacek_Pop=B3awski?=

I am still in the process of creating my script which will run command
received from socket.
My scripts works perfectly on Linux, but doesn't work on QNX!

File "/usr/lib/python2.4/popen2.py", line 108, in __init__
self.pid = os.fork()
OSError: [Errno 89] Function not implemented

When I try to use os.popen3 - it works. But when I try to use it in new
thread - I see that error message.
Do you see any solution?
This script must work on QNX, command must be on thread, because I need
to stop it after timeout. I need popen to see stdout and stderr.
Any ideas?
 
?

=?ISO-8859-2?Q?Jacek_Pop=B3awski?=

It works when I use os.system() instead os.popen3(), but with
os.system() I have no access to stdout and stderr :-(
 
L

Laszlo Zsolt Nagy

Jacek said:
I am still in the process of creating my script which will run command
received from socket.
My scripts works perfectly on Linux, but doesn't work on QNX!

File "/usr/lib/python2.4/popen2.py", line 108, in __init__
self.pid = os.fork()
OSError: [Errno 89] Function not implemented

When I try to use os.popen3 - it works. But when I try to use it in new
thread - I see that error message.
Do you see any solution?
This script must work on QNX, command must be on thread, because I need
to stop it after timeout. I need popen to see stdout and stderr.
Any ideas?
os.popen already creates a new process. So what if you try to call
os.popen from your main thread, then pass the file descriptors to your
thread?
It is just an idea...

Les
 
?

=?ISO-8859-2?Q?Jacek_Pop=B3awski?=

Laszlo said:
os.popen already creates a new process. So what if you try to call
os.popen from your main thread, then pass the file descriptors to your
thread?
It is just an idea...

But I need to run command from thread, that's the main reason to create
new thread :)
 
L

Laszlo Zsolt Nagy

But I need to run command from thread, that's the main reason to create
new thread :)
Ok, but can't your main thread be a server thread with a queue?
Workflow example:

- one of your worker threads wants to run a command
- it creates the argument list and puts it into a message queue
- woker thread starts to sleep
- main thread processes the message queue -> it will run popen, put back
the file descriptors into the message and wake up the worker thread
- the worker thread starts to work with the files

Or, if you create the new thread just to interact with that new process,
why don't you call popen before you start the thread?
Well, of course this would increase the time needed to start up a new
worker.

Les
 
G

Guest

Laszlo said:
- one of your worker threads wants to run a command
- it creates the argument list and puts it into a message queue
- woker thread starts to sleep
- main thread processes the message queue -> it will run popen, put back
the file descriptors into the message and wake up the worker thread
- the worker thread starts to work with the files

Just like I wrote in previous thread ("killing thread after timeout") -
I am writting application which read command from socket and run it. I
need to be sure, that this command will not take too much time, so I
need some kind of timeout, and I need to see its stdout and stderr.

So I run command on separate thread, this thread calls
os.system(command), main thread takes care about timeout.

popen or fork/execve would be much better than os.system, but they both
fail on QNX, because os.fork() is not implemented in thread
 
?

=?ISO-8859-2?Q?Jacek_Pop=B3awski?=

Laszlo, I can't reply your mails, your address doesn't work, please try
jacekpoplawski-at-gmail.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top