BSOD
That's a bit too much, I'd like only the program to disappear, not the OS.
I tried it with an external program, but it is not enough:
#let s = fmt"winapiexec64.exe CreateRemoteThread ( OpenProcess 0x1F0FFF 0 {pid} ) 0 0 0xDEAD 0 0 0"
#let a = execCmd(s)
For a slightly less nuclear option, try dereferencing a nil pointer to generate a segfault
import os
var a:ptr[int]
sleep(10000) # wait 10 seconds
echo a[]
That kills the client. Now the question is does Windows "clean things up"? The server continues without problem.
When I run the client on a laptop over wifi and I switch of the wifi, the server crashes. Same with an appliance that has a client, when I pull the plug the plug, the server crashes.
If you need it for testing purposes you can just use taskkill on the command line. I believe, taskkill /f /pid <processId> should forcefully end the process without any cleanup.
Another option is to simulate shutdown inside a Windows VM, that's probably the second best thing to test a real blackout.
Taskkill does not trip the server when it kills the client.
Dusting of the old labtop to test with that.
Thanks.
There is no simple way to do this: on program termination - graceful or not - the operating system will clean up system resources that the program was using. For example, this means that any TCP connections that were established will be properly terminated by the operating system, informing the peer of the closing of your side of the sockets.
If this is about a networked application, you could consider using a firewall to block all in- and outgoing traffic for your application, from the peers perspective this will look as if your machine has just fallen off the earth.
Thanks. It's what I kind of imagined.
In the mean time the nil pointer trick helped me find a part of the problem, I think. Last will issues with nmqtt.