add Windows ForkExec, Syscall12
Updated script that generates syscalls to use them if need be.
Added windows ForkExec to windows. Needs tracing, env, and Fd added still.
Renamed syscall/exec.go to exec_unix.go.
On 2010/06/07 03:56:05, kardia wrote: > Hello brainman, rsc1 (cc: mailto:golang-dev@googlegroups.com), > > I'd like ...
14 years, 5 months ago
(2010-06-08 07:18:24 UTC)
#4
On 2010/06/07 03:56:05, kardia wrote:
> Hello brainman, rsc1 (cc: mailto:golang-dev@googlegroups.com),
>
> I'd like you to review this change.
Thanks for making the effort.
I tried to write small program similar to src\pkg\exec\exec_test.go, like so:
cmd, err := exec.Run("c:\\winnt\\system32\\netstat.exe", []string{"netstat"},
nil, "",
exec.DevNull, exec.Pipe, exec.DevNull)
if err != nil {
abortf("run: %s\n", err)
}
buf, err := ioutil.ReadAll(cmd.Stdout)
if err != nil {
abortf("read: %s\n", err)
}
fmt.Printf("buf: %v\n", buf)
if err = cmd.Close(); err != nil {
abortf("close: %s\n", err)
}
but it fails with
C:\TMP>\\sos\pub\test
run: open /dev/null: The system cannot find the path specified.
Do you have a small program that runs?
Alex
> cmd, err := exec.Run("c:\\winnt\\system32\\netstat.exe", > []string{"netstat"}, nil, "", > exec.DevNull, exec.Pipe, exec.DevNull) Right now ...
14 years, 5 months ago
(2010-06-08 13:43:38 UTC)
#5
> cmd, err := exec.Run("c:\\winnt\\system32\\netstat.exe",
> []string{"netstat"}, nil, "",
> exec.DevNull, exec.Pipe, exec.DevNull)
Right now the working dir is mandatory. Give it a real path, such as
"C:\\". If you don't it will complain. For consistency, this is one of
the issues that might need to tested for. I'll add a comment to the
code for now.
http://codereview.appspot.com/1578041/diff/11018/26004 File src/pkg/syscall/exec_windows.go (right): http://codereview.appspot.com/1578041/diff/11018/26004#newcode109 src/pkg/syscall/exec_windows.go:109: // 0x00000400 = UNICODE env Do not need the ...
14 years, 5 months ago
(2010-06-11 11:16:37 UTC)
#12
http://codereview.appspot.com/1578041/diff/11018/26004
File src/pkg/syscall/exec_windows.go (right):
http://codereview.appspot.com/1578041/diff/11018/26004#newcode109
src/pkg/syscall/exec_windows.go:109: // 0x00000400 = UNICODE env
Do not need the comment about UNICODE now.
http://codereview.appspot.com/1578041/diff/11018/26006
File src/pkg/syscall/syscall_windows.go (right):
http://codereview.appspot.com/1578041/diff/11018/26006#newcode132
src/pkg/syscall/syscall_windows.go:132: //sys CreateProcess(appName *int16,
commandLine *uint16, procSecurity *int16, threadSecurity *int16, inheritHandles
int16, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo
*StartupInfo, outProcInfo *ProcessInformation) (ok uint32, errno int)
[failretval=0] = CreateProcessW
inheritHandles is not int16, it is 4 bytes long, you will get away with it here,
because in zsyscall_windows_386.go it is converted to uintptr anyway, but if you
do it in a struc, you will get burned.
If you make it inheritHandles bool, this:
diff -r a9f764657223 src/pkg/syscall/mksyscall_windows.sh
--- a/src/pkg/syscall/mksyscall_windows.sh Thu Jun 10 13:30:39 2010 -0700
+++ b/src/pkg/syscall/mksyscall_windows.sh Fri Jun 11 12:54:47 2010 +1000
@@ -133,6 +133,11 @@
} else {
push @args, "uintptr($name)", "uintptr($name >>
32)";
}
+ } elsif($type eq "bool") {
+ $text .= "\tvar _p$n uint32;\n";
+ $text .= "\tif $name { _p$n = 1; } else { _p$n = 0;
}\n";
+ push @args, "uintptr(unsafe.Pointer(_p$n))";
} else {
push @args, "uintptr($name)";
}
should take care of it. Then you don't need to think twice what you must pass to
have your handles inherited - "0" or "1" or "-1" or "9999", it will be "true".
http://codereview.appspot.com/1578041/diff/11018/26006#newcode132
src/pkg/syscall/syscall_windows.go:132: //sys CreateProcess(appName *int16,
commandLine *uint16, procSecurity *int16, threadSecurity *int16, inheritHandles
int16, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo
*StartupInfo, outProcInfo *ProcessInformation) (ok uint32, errno int)
[failretval=0] = CreateProcessW
Return values should be:
(ok bool, errno int) = CreateProcessW
like all other similar functions.
http://codereview.appspot.com/1578041/diff/11018/26008
File src/pkg/syscall/ztypes_windows_386.go (right):
http://codereview.appspot.com/1578041/diff/11018/26008#newcode175
src/pkg/syscall/ztypes_windows_386.go:175: _ uint8
It is *byte (4 bytes long), not uint8 (1 byte long).
Bug like that would be difficult to find - offsets of StdInput, StdOutput,
Stderr are now wrong and windows will not find you parameters there.
Made changes and modified for recent syscall change. Tested, appears to function. Thank you for ...
14 years, 5 months ago
(2010-06-14 01:34:46 UTC)
#13
Made changes and modified for recent syscall change. Tested, appears to
function. Thank you for your patience.
http://codereview.appspot.com/1578041/diff/11018/26004
File src/pkg/syscall/exec_windows.go (right):
http://codereview.appspot.com/1578041/diff/11018/26004#newcode109
src/pkg/syscall/exec_windows.go:109: // 0x00000400 = UNICODE env
On 2010/06/11 11:16:37, brainman wrote:
> Do not need the comment about UNICODE now.
Removed
http://codereview.appspot.com/1578041/diff/11018/26006
File src/pkg/syscall/syscall_windows.go (right):
http://codereview.appspot.com/1578041/diff/11018/26006#newcode132
src/pkg/syscall/syscall_windows.go:132: //sys CreateProcess(appName *int16,
commandLine *uint16, procSecurity *int16, threadSecurity *int16, inheritHandles
int16, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo
*StartupInfo, outProcInfo *ProcessInformation) (ok uint32, errno int)
[failretval=0] = CreateProcessW
Nice. Had to remove unsafe.Pointer, as it is a value.
http://codereview.appspot.com/1578041/diff/11018/26006#newcode132
src/pkg/syscall/syscall_windows.go:132: //sys CreateProcess(appName *int16,
commandLine *uint16, procSecurity *int16, threadSecurity *int16, inheritHandles
int16, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo
*StartupInfo, outProcInfo *ProcessInformation) (ok uint32, errno int)
[failretval=0] = CreateProcessW
On 2010/06/11 11:16:37, brainman wrote:
> Return values should be:
>
> (ok bool, errno int) = CreateProcessW
>
> like all other similar functions.
Done.
http://codereview.appspot.com/1578041/diff/11018/26008
File src/pkg/syscall/ztypes_windows_386.go (right):
http://codereview.appspot.com/1578041/diff/11018/26008#newcode175
src/pkg/syscall/ztypes_windows_386.go:175: _ uint8
On 2010/06/11 11:16:37, brainman wrote:
> It is *byte (4 bytes long), not uint8 (1 byte long).
> Bug like that would be difficult to find - offsets of StdInput, StdOutput,
> Stderr are now wrong and windows will not find you parameters there.
There are time I feel silly. This is one of them.
Done.
14 years, 5 months ago
(2010-06-15 01:35:09 UTC)
#15
http://codereview.appspot.com/1578041/diff/34001/35008
File src/pkg/syscall/syscall_windows.go (right):
http://codereview.appspot.com/1578041/diff/34001/35008#newcode132
src/pkg/syscall/syscall_windows.go:132: //sys CreateProcess(appName *int16,
commandLine *uint16, procSecurity *int16, threadSecurity *int16, inheritHandles
bool, creationFlags uint32, env *uint16, currentDir *uint16, startupInfo
*StartupInfo, outProcInfo *ProcessInformation) (ok bool, errno int)
[failretval=0] = CreateProcessW
Return values should be:
(ok bool, errno int) = CreateProcessW
You do not need [failretval=0] here. failretval is 0 by default, see
mksyscall_windows.sh. And having return value of type "bool" fits that notion
well.
On 2010/06/30 21:02:34, kardia wrote: > Hello brainman, rsc (cc: mailto:golang-dev@googlegroups.com), > > Please take ...
14 years, 4 months ago
(2010-06-30 21:03:30 UTC)
#20
On 2010/06/30 21:02:34, kardia wrote:
> Hello brainman, rsc (cc: mailto:golang-dev@googlegroups.com),
>
> Please take another look.
Updated patch set to merge with tip.
Daniel, > Updated patch set to merge with tip. > It's out of date again. ...
14 years, 4 months ago
(2010-07-12 23:42:37 UTC)
#21
Daniel,
> Updated patch set to merge with tip.
>
It's out of date again.
Now that Russ is back, would you like to refresh your change and will
get it moving.
Thank you.
Alex
I know people are busy but is there interest or comments to this? Thanks, -Daniel ...
14 years, 4 months ago
(2010-07-19 14:32:24 UTC)
#24
I know people are busy but is there interest or comments to this?
Thanks,
-Daniel
On 2010/07/13 02:41:43, brainman wrote:
> On 2010/06/07 20:01:07, rsc1 wrote:
> > ...
>
> Ping.
On 2010/07/19 14:32:24, kardia wrote: > I know people are busy but is there interest ...
14 years, 4 months ago
(2010-07-19 23:43:05 UTC)
#25
On 2010/07/19 14:32:24, kardia wrote:
> I know people are busy but is there interest or comments to this?
I can't submit your patch. But anyway you look at it, we need to implement
ForkExec(), even so we can just make goinstall to work. So, I suggest, you
continue, if you like. Get your goal to make goinstall work as intended, and do
whatever required.
Thank you.
Alex
Thanks very much for working on this. This looks good to me but I'd like ...
14 years, 4 months ago
(2010-07-20 06:09:29 UTC)
#26
Thanks very much for working on this.
This looks good to me but I'd like to see the environment
and fd slices addressed before we submit it. The traceme
flag doesn't matter as much - it's just for the debugging library,
which isn't much used even on Linux.
The environment should be an argument to CreateProcess,
and the fd slice can turn into the three arguments passed
in the STARTUPINFO. It's okay to return an error when
len(fd) > 3.
Russ
Russ, I wans't sure about the exact desired behavior of ForkExec. I'v e made the ...
14 years, 4 months ago
(2010-07-22 00:21:50 UTC)
#27
Russ, I wans't sure about the exact desired behavior of ForkExec. I'v e made
the following comment:
//Behavior:
// If envv is passed nil, then it uses the parent env
// If a fd is nil, contains value <= 0, or not present, then it uses the parent
StdIn/Out/Err
However, I'm not sure if this matches up with how it behaves on unix. Please
advise. Thanks,
-Daniel
On 2010/07/20 06:09:29, rsc wrote:
> Thanks very much for working on this.
>
> This looks good to me but I'd like to see the environment
> and fd slices addressed before we submit it. The traceme
> flag doesn't matter as much - it's just for the debugging library,
> which isn't much used even on Linux.
>
> The environment should be an argument to CreateProcess,
> and the fd slice can turn into the three arguments passed
> in the STARTUPINFO. It's okay to return an error when
> len(fd) > 3.
>
> Russ
>
kardianos@gmail.com writes: > Russ, I wans't sure about the exact desired behavior of ForkExec. I'v ...
14 years, 4 months ago
(2010-07-22 08:59:07 UTC)
#28
kardianos@gmail.com writes:
> Russ, I wans't sure about the exact desired behavior of ForkExec. I'v e
> made the following comment:
>
> //Behavior:
> // If envv is passed nil, then it uses the parent env
> // If a fd is nil, contains value <= 0, or not present, then it uses the
> parent StdIn/Out/Err
>
> However, I'm not sure if this matches up with how it behaves on unix.
On Unix, the environment passed to ForkExec is the environment that the
child process gets. If you want the child to get the same environment
sa the parent, pass in os.Environ().
The fd array is the set of file descriptors passed to the child. If the
array is nil the child starts with no open file descriptors. If an
entry in the array is less than 0, that file descriptor is not open when
the child starts. So, again, the child does not inherit from the
parent by default.
Ian
I don't know much about this process. I think the only way we'll find out ...
14 years, 4 months ago
(2010-07-23 06:48:14 UTC)
#30
I don't know much about this process. I think the only way we'll find out is by
testing it. LGTM.
Just one thing, the fds you pass to new process aren't inheritable. All current
apis create fds with non-inheritable flag (by default). So, again, we'll have to
test all that.
Alex
On a side note, I have tested the functionality and the fds and envv vars ...
14 years, 4 months ago
(2010-07-23 14:23:26 UTC)
#32
On a side note, I have tested the functionality and the fds and envv
vars appear to function in the way described by the unix version. I
have to give startup info to each stdin/out/err so that if nothing is
passed, then it doesn't get a valid stdout. It's rather ironic, in
order to not inherit fds, you have to inherit fds :) .
Thanks,
-Daniel
On 07/22/2010 11:48 PM, alex.brainman@gmail.com wrote:
> I don't know much about this process. I think the only way we'll find
> out is by testing it. LGTM.
>
> Just one thing, the fds you pass to new process aren't inheritable. All
> current apis create fds with non-inheritable flag (by default). So,
> again, we'll have to test all that.
>
>
> Alex
>
> http://codereview.appspot.com/1578041/show
Issue 1578041: code review 1578041: add Windows ForkExec, Syscall12
(Closed)
Created 14 years, 5 months ago by kardia
Modified 12 years, 6 months ago
Reviewers:
Base URL:
Comments: 21