Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows script auto-update replacing current executable with exec?

I'm trying to build a quick auto-updater in Perl Windows. I've noticed that when I call cpanp to install the update of the package it fails to install a new version of the script because the script is currently running. I'm calling cpanp with CORE::system() currently. If I called cpanp with exec() would that release the executable for replacement? Or, does Windows keep it tied up even though execution has been turned over entirely to cpanp?

Currently, my process flow looks something like this,

  1. Download META.yml from server
  2. Parse out the version of META.yml
  3. Compare against the current $VERSION
    • If the current version is lower, generate a version string using the data in META.yml
      1. Generate a URL to package using the host/path fo META.yml and the version/data information
      2. Inform user of update
      3. Spawn cpanp to run update with URL.
    • If the current version is the same
      1. Do nothing

Would system() behave differently than exec() on Win32 with regard to replacement of the executable? On Linux it works as designed.

like image 902
NO WAR WITH RUSSIA Avatar asked Jun 03 '13 16:06

NO WAR WITH RUSSIA


1 Answers

I just tested it. exec works as it should on both Linux and Win32. See this page for portability info on Perl.

like image 142
Francisco Zarabozo Avatar answered Sep 20 '22 06:09

Francisco Zarabozo