By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,270 Members | 1,703 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,270 IT Pros & Developers. It's quick & easy.

popen in thread on QNX

P: n/a
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?
Sep 8 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
It works when I use os.system() instead os.popen3(), but with
os.system() I have no access to stdout and stderr :-(
Sep 8 '05 #2

P: n/a
Jacek Popławski wrote:
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

Sep 8 '05 #3

P: n/a
Laszlo Zsolt Nagy wrote:
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 :)
Sep 8 '05 #4

P: n/a
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 :)

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

Sep 8 '05 #5

P: n/a
Laszlo Zsolt Nagy wrote:
- 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
Sep 8 '05 #6

P: n/a
spawn() works on QNX, fork() does not.

Sep 8 '05 #7

P: n/a
Laszlo, I can't reply your mails, your address doesn't work, please try
jacekpoplawski-at-gmail.com
Sep 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.