473,396 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

popen in thread on QNX

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
7 3226
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
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
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
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
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
spawn() works on QNX, fork() does not.

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

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Bryan | last post by:
i have a batch file that contains these two lines: -- args.bat echo %1 echo %2 when i run args.bat from the command line it works correctly... notice that abc has quotes in the first...
0
by: Fortepianissimo | last post by:
Just a quick question: are popen*() thread-safe? I'm using popen() and popen2() in a heavily threaded script and seem to have some stability problem (just hangs). (also it looks like the python...
1
by: Steve | last post by:
Hi, I have a couple of threads running in my program and I tried to do the following from one thread: out = os.popen("su -l postgres -c \"psql -c 'VACUUM ANALYZE table1' -d my_db\"") This...
2
by: Your Friend | last post by:
Hello All, I'm relatively new to Python programming but have been working on this problem for a little bit now ... I initially began writing UNIX scripts in Python and thought it was the...
2
by: revenant81 | last post by:
I'm writing a program which has to execute a command, get its output and show it on a treeview. This command runs for a very long time. I want to end the execution of the command when the user...
4
by: zane.selvans | last post by:
Hi there, I've been banging my head against this for a day, and I can't take it anymore. It's probably a stupid error, but I don't see where. I'm trying to use Python to call an external...
3
by: Mathieu Prevot | last post by:
Hi it seems the script (A) finishes before the downloading ends, and the (B) version doesn't (wanted behavior) ... this is unexpected. What happens ? (A)...
25
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the...
2
by: dudeja.rajat | last post by:
On Mon, Sep 8, 2008 at 11:50 AM, <dudeja.rajat@gmail.comwrote: Ok, I re-phrase my question: there is a batch file that executes a exe file. The batch just works if run from command prompt and...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.