os.system() inside a thread problem

D

Daniel Bernhardt

Hello,

my thread calls a program with os.system().
os.system("/usr/bin/wine /path/to/ultima/online.exe")
Ultima Online is starting and i can enter commands and navigate through the
game with my keyboard. If I move the mouse over the Ultima Online window
Ultima Online crashes. (the mouse just need to overlap 1 pixel of the egde
of the window. titlebar inlcuded)
/usr/bin/wine: line 55: 11675 Segmentation fault
Same with os.popen()

If I run os.system() outside the thread everything is working like expected.
Other programs (wine emulated and nativ) work inside and outside the thread.

Can anyone tell me how I can fix this?
Google told me simillar problems were fixed by upgrading to python 2.4. that
is no option for me.

Thanks,
Daniel


some example code:

from threading import Thread
runuo = StartUO(command)
runuo.start()

class StartUO(Thread):
def __init__(self,command):
Thread.__init__(self)
self.command = command
def run(self):
os.execv(self.command)
 
F

Fredrik Lundh

Daniel said:
my thread calls a program with os.system().

in the example you included, you use execv. which one is it?
Ultima Online is starting and i can enter commands and navigate through the
game with my keyboard. If I move the mouse over the Ultima Online window
Ultima Online crashes. (the mouse just need to overlap 1 pixel of the egde
of the window. titlebar inlcuded)
Same with os.popen()

If I run os.system() outside the thread everything is working like expected.
Other programs (wine emulated and nativ) work inside and outside the thread.

Can anyone tell me how I can fix this?

just curious: do you really have to use a thread? why not just do

os.system(command + "&")

</F>
 
D

Daniel Bernhardt

Fredrik said:
in the example you included, you use execv. which one is it?

it should be system(). I just played a bit and forgot to change it back.
just curious: do you really have to use a thread? why not just do

os.system(command + "&")

No, i don't need to use a thread. I just wanted learn something about it and
thought it would be a good start.
I will use "os.system(command + "&")" as you said to solve the problem.
Thanks.
 

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

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top