3 ms·
the windows implementation seems awfully complex. what's wrong with something like _popen("find \"\" & del " + argv[0])? the problem to solve is "we can't delet
by Hello71 3y ago
the windows implementation seems awfully complex. what's wrong with something like _popen("find \"\" & del " + argv[0])? the problem to solve is "we can't delete ourselves, so we need something else to do it for us", but there are a myriad options to choose from, you don't have to write it in rust. hell, you've already got the dubious sleep(100) in there, you can even write _popen("ping 127.0.0.1 & del " + argv[0]) as suggested by stack overflow?
- paulddraper 3y agoNot a Windows programmer, but doesn't it prevent a file from being deleted while it is being used/executed? (At least not without black magic?)
- ilyt 3y agoStupid trick would be to copy to temporary file and run that file, then update the original now-not-used one. Tho that might be weird enough to trigger AV
- the_mitsuhiko 3y agoI tried plenty of approaches on windows, this was the one that seems the most reliable and least problematic. It's also the approach other systems already use.