1

I have a script

$ cat PDFX.sh 
#! /bin/bash
wine /home/t/pdfxcview/PDFXCview.exe

In an interactive bash shell, I run

$ ./PDFX.sh &
[1] 21740

and then try to kill it

$ kill $(jobs -p)
[1]+  Terminated              ./PDFX.sh

It says "Terminated", but the program PDFXCview.exe is still running without being affected, and it can even survive after I exit the shell

$ exit
  • If I replace wine /home/t/pdfxcview/PDFXCview.exe in the script with evince, it won't survive the kill command and the termination of the shell.

  • if I run wine /home/t/pdfxcview/PDFXCview.exe & directly in the interactive bash shell, it won't survive the kill command and the termination of the shell.

I was wondering why the difference?

I don't think there is something special about wine.

  • The shell process died but wine ignores the signal? – Kusalananda May 5 '18 at 15:07
  • I guess yes..... – Tim May 5 '18 at 15:18
  • Or wine forked off a process? – Jeff Schaller May 5 '18 at 15:18
3

Running

wine /home/t/pdfxcview/PDFXCview.exe

will normally result in a number of processes starting up, to provide the typical Windows environment a Windows binary expects (explorer.exe etc.). Wine starts all these processes via wineserver, and detaches them all — so they are not children of your shell, nor even of wineserver. The binary you asked Wine to run can be a child process of the shell, but it’s also disowned so that it can outlive its parent. Exiting the shell from which you started all these processes doesn’t affect them.

To kill a Windows program, you need to find its pid and kill that directly. You can kill all Wine processes with wineserver -k.

When you run PDFX.sh &, a new shell is started to process the script, and that shell runs Wine to start PDFXCview.exe. When you run kill %1, you’re killing the shell running the script, not the Wine process. The Wine process continues running (re-parented to pid 1).

When you run wine /home/t/pdfxcview/PDFXCview.exe &, the Wine process is started directly. When you then run kill %1, you’re killing the Wine process, which stops the Windows program. If no other Windows program is running, wineserver should terminate shortly thereafter.

  • Thanks. If I run wine /home/t/pdfxcview/PDFXCview.exe & directly in the interactive bash shell, it won't survive the kill command and the termination of the shell. Why the difference? – Tim May 5 '18 at 15:31
  • By "your second example", do you mean running wine /home/t/pdfxcview/PDFXCview.exe & directly in the interactive bash shell? In the original example where I run ./PDFX.sh & in an interactive bash shell, what does the shell job correspond to, and what does kill %1 kill? – Tim May 5 '18 at 16:29
  • Thanks. Appreciate it if you could take a chance at unix.stackexchange.com/questions/446387/…? – Tim May 28 '18 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.