4

(I'm not a Linux or Wine pro... they were set up by an IT guy... I'm just a java guy) I'm working on a java application which runs on Linux. It spawns several threads that do the same thing, namely spawning processes (java.lang.Process), some Linux, some Windows through wine. Some of my threads will hang indefinitely during the wine calls.

Because I have several threads going that call the same linux/windows apps, I can't just grep the ps output for wine and kill that because I could kill wine processes that are fine.

Did some googling, and through reflection I'm able to get the pid from the process but it doesn't correspond to a Linux pid using ps, so I'm thinking it's a pid running in wine.

(Finally the question...) Is there a way to kill a process running in wine referencing it's pid?

jgreen
  • 1,132
  • 2
  • 14
  • 18

4 Answers4

5

To kill all Wine processes, use wineserver -k (all within same WINEPREFIX environment).

For killing specific process (list by winedbg --command "info proc"), you can run winedbg in the following way:

Then run winedbg in the following way:

$ winedbg
Wine-dbg>info proc
 pid      threads  executable (all id:s are in hex)
 0000000d 4        'taskmgr.exe'
 0000000e 4        'services.exe'
 0000001a 3        \_ 'plugplay.exe'
Wine-dbg>attach 13
0x9f68ad05 read$UNIX2003+0x5 in libsystem_kernel.dylib: call    0x9f68b40c _sysenter_trap in libsystem_kernel.dylib
Wine-dbg>kill
Wine-dbg>quit

Since attach accepts a decimal value, you need to convert its pid from hexadecimal, here is example in Bash shell:

echo $(( 0x0000000d ))
kenorb
  • 155,785
  • 88
  • 678
  • 743
3

Wine, at least in recent versions, does come with its own taskmgr and taskkill, analogous to the programs by the same name on Windows.

ephemient
  • 198,619
  • 38
  • 280
  • 391
1

When you do kill -3 PID where PID is id of Wine process you interested in, you'll get JVM thread dump on the console where you've launched that process. This dump will contain list of threads with theirs current state, and will contain nid field which is equal to SPID field in output of ps -ef -T.

Victor Sorokin
  • 11,878
  • 2
  • 35
  • 51
  • 1
    Thanks for your response. In trying what you suggest, the pid is not recognized. -bash-3.2$ kill -3 5245 -bash: kill: (5245) - No such process While this is consistent with my comment in my OP "I'm able to get the pid from the process but it doesn't correspond to a Linux pid using ps", in taking another look at it I think I may have been on the wrong track. Perhaps more detail is needed... After the process is initially started, I spawn another thread that transfers the process's output stream using a buffer. ... – jgreen Dec 31 '10 at 01:49
  • When the process returns a result letting me know it's finished, I then wait for the thread doing the stream transfer to finish. The thread doing the stream transfer is actually where the hang happens (if it happens). I think somehow the process output stream is not letting the buffer know it should be done (by returning -1 for number of bytes read) and so it get blocked on the read operation. That's actually what I want to be killing, but it occurrs to me that the process pid probably doesn't point to anything because the process is done. ... – jgreen Dec 31 '10 at 01:51
  • I've assumed the hung stream transfer would cause the process to still be active. I guess I'm back to some kind of java solution, if there is one. – jgreen Dec 31 '10 at 01:51
0

If you get too frustrated, try a Windows task manager. It should be able to see the wine processes as native. (Of course it won't see the others at all so the total won't add up to 100%).

Joshua
  • 40,822
  • 8
  • 72
  • 132