os.system() inside a thread problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Daniel Bernhardt

    #1

    os.system() inside a thread problem

    Hello,

    my thread calls a program with os.system().[color=blue]
    > os.system("/usr/bin/wine /path/to/ultima/online.exe")[/color]
    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)[color=blue]
    > /usr/bin/wine: line 55: 11675 Segmentation fault[/color]
    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,c ommand):
    Thread.__init__ (self)
    self.command = command
    def run(self):
    os.execv(self.c ommand)
  • Fredrik Lundh

    #2
    Re: os.system() inside a thread problem

    Daniel Bernhardt wrote:
    [color=blue]
    > my thread calls a program with os.system().[color=green]
    >> os.system("/usr/bin/wine /path/to/ultima/online.exe")[/color][/color]

    in the example you included, you use execv. which one is it?
    [color=blue]
    > 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)[color=green]
    >> /usr/bin/wine: line 55: 11675 Segmentation fault[/color]
    > 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?[/color]

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

    os.system(comma nd + "&")

    </F>



    Comment

    • Daniel Bernhardt

      #3
      Re: os.system() inside a thread problem

      Fredrik Lundh wrote:
      [color=blue]
      > in the example you included, you use execv. which one is it?[/color]

      it should be system(). I just played a bit and forgot to change it back.
      [color=blue]
      >
      > just curious: do you really have to use a thread? why not just do
      >
      > os.system(comma nd + "&")
      >[/color]

      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(comm and + "&")" as you said to solve the problem.
      Thanks.

      Comment

      Working...