Graceful shutdown (Windows daemon)

Ask for help and report issues with the Windows version of Transmission
Post Reply
dayz99
Posts: 3
Joined: Sun Feb 25, 2018 5:36 am

Graceful shutdown (Windows daemon)

Post by dayz99 »

Hi,

How to close gracefully the transmission-daemon on Windows?

In Linux I send the SIGTERM command.

In Windows the equal command is

by process name:
taskkill /im transmission-daemon.exe

or by PID:
taskkill /pid <####>

Problem is that transmission-daemon.exe does not respond to the graceful taskkill.

Instead I must use the /f switch to force shutdown: taskkill /f /im transmission-daemon.exe

I would like if it can be possible to make transmission-daemon.exe respond to gracefully close without force. This way to allow it to stop torrents or save data/settings that might not be saved yet.

I would like to note that I don't run transmission-daemon.exe as a windows service. I run it as a normal process in the background for a certain number of reasons. Thank you for any help. :D
mike.dld
Transmission Developer
Posts: 306
Joined: Wed Dec 25, 2013 10:56 pm

Re: Graceful shutdown (Windows daemon)

Post by mike.dld »

taskkill (w/o /f) works fine for me on Windows 8. What Windows version do you have? What Transmission version do you have?
dayz99
Posts: 3
Joined: Sun Feb 25, 2018 5:36 am

Re: Graceful shutdown (Windows daemon)

Post by dayz99 »

Hi,

In this system I am running with Windows 7

Downloaded Transmission from this link exactly:
https://github.com/transmission/transmi ... 92-x86.msi
MD5: e10105ca6e06d4f73668c212af60b39c
SHA1: 8577712d7cd6ddc6cffc9e44e47c705c85945593


I installed the setup file transmission-2.92-x86.msi in a Virtual Windows 7 OS just to retrieve only the transmission-daemon.exe file. Once I have this file copied I delete the Virtual OS and run the transmission-daemon.exe file in the normal OS. I do it this way because I don't want to install the service and there was no portable/zip download available.

transmission-daemon.exe --version
> transmission-daemon 2.92 (14714)
MD5: 0f3d970b503f3b08cbe018c59cdfa6b7
SHA1: b9d30ee56d375487889e5ab4e6c9c93fb7cc989c


When I run transmission-daemon.exe I tried it normally as background app daemonized, also tried it with the --foreground switch to see if it's different.

In both ways I cannot taskkill transmission-daemon.exe, which reports the error:

taskkill /im transmission-daemon.exe
> ERROR: The process "transmission-daemon.exe" with PID 3643 could not be terminated.
> Reason: This process can only be terminated forcefully (with /F option).

If you have some ideas let me know. I will try tomorrow in another system. Normally I'm using transmission on Linux but this is the first time I'm trying on Windows. Normally I don't have problems of this nature but since it works for you then I will check it again in another system to see what happens that way.
mike.dld
Transmission Developer
Posts: 306
Joined: Wed Dec 25, 2013 10:56 pm

Re: Graceful shutdown (Windows daemon)

Post by mike.dld »

Option #1, obviously, is to use a newer Windows version.

Option #2 is to try programs like the one(s) mentioned in https://stackoverflow.com/q/813086/583456 (or write your own) to send the daemon the Crtl+C event instead of WM_CLOSE that taskkill on Windows 7 seems to be doing.

Option #3 is, if you have access to the console window that the daemon creates when started in foreground, and if you're okay with stopping it manually, is to switch to that window and press Ctrl+C.
dayz99
Posts: 3
Joined: Sun Feb 25, 2018 5:36 am

Re: Graceful shutdown (Windows daemon)

Post by dayz99 »

ctrl+c event works. I will use option #2 to make my own program to do it. But for now just made a simple launcher to run in the foreground and hide the window so it is like daemonized. I can bring back the window to ctrl+c when I need to close. Thanks. :D
Post Reply