Tue 29 Nov 2005 06:47:02 PM UTC, original submission:
Hello,
This patch implements/fixes Process.StartInfo.WorkingDirectory parameter and fixes some other related problems.
I have added workingDir parameter to StartProcess() internal call. This means, that applying this patch involves:
- patch Process.cs
- rebuild pnetlib
- run mkint.sh in pnet/engine
- patch lib_task.c
- commit
Things that have been done:
1) Fixed obvious typo in Process.cs line 915. Path.PathSeparator was used to combine path, whitch is invalid because it is char ':'. Path.Combine() or Path.DirectorySeparator should be used instead.
2) WorkingDirectory is implemented to behave the same way as in .NET. I had to write a test programs to find out the behaviour, because MSDN documentation does not correspond to .NET implementation (and according to these documents, WorkingDirectory would be quite useless). Implementation behaves now like following:
a) WorkingDirectory is always directory where the new process is started - figures as CurrentDirectory in started process
b) if(UseShellExecute==true && FileName is realative path)
{
combine WorkingDirectory + Filename and start process from that location.
}
c) if(UseShellExecute==false)
{
directly start process where FileName points to executable location (do not combine WorkingDirectory and FileName)
}
3) There was added a line to clear errno in the beginning of cygwin part for _IL_Process_StartProcess(). Errno was hanging there from some previous operation e.g. from ILFileExists(). This caused that checking for Errno always threw exception (Process.cs line 946).
4) Above mentioned checking for Errno is now done conditionaly - only when _IL_Process_StartProcess() returns false. (Did it make sense to check for error if that function returned success?)
5) Added passing of workingDir parameter to CreateProcess (cygwin part). Added ILChangeDir() to switch current directory in forked process (linux).
I've also attached simple test program, that prints process start parameters, and start process that prints it's current directory (standard pwd program for unices, message box with current dir for windows).
Patch works for me on gentoo/cygwin though I will do some more testing tommorow, because i had to finnish it in time pressure.
Thanks to KlausT and MarcusU for help.
|