I'm using Python 2.6 on Windows 7. I have Windows .cmd file which invokes Python to run the CherryPy Web server (version 3.1.2). I start this .cmd file by executing it at the prompt in a Windows CMD shell. When CherryPy notices that one of its dependent files has changed, it restarts. There are a couple problems that arise in this configuration on Windows, because the invocation that CherryPy uses to restart itself is
os.execv(sys.executable, args)
but you can't invoke the Python executable on the .cmd file. I've managed to bypass that problem through various Python gymnastics, and now I've got it restarting by calling (essentially)
os.execv(sys.argv[0], args)
But the restarted process is detached from the keyboard; it will catch Ctrl-C, and then I'm asked
Terminate batch job (Y/N)?
but the Y or N I type is caught not by the terminating .cmd file, but by the Windows CMD shell, and it responds
'Y' is not recognized as an internal or external command, operable program or batch file.
So how do I set things up in Windows to keep the restarted process in what I'd call "the foreground" in Unix?