Re: [go-nuts] Sending and receiving on file descr other than stdin/out/err

2018-04-20 Thread Robert Bielik
Den fredag 20 april 2018 kl. 16:11:36 UTC+2 skrev Ian Lance Taylor:
>
> On Fri, Apr 20, 2018 at 7:09 AM, Robert Bielik  > wrote: 
> >> 
> >> Look at how os.Stdin and friends are initialized in os/file.go. 
> >> https://golang.org/src/os/file.go#L51 . 
> > 
> > 
> > Hmm... the syscall vars are platform specific. Is there a way to do this 
> > cross-platform ? 
> > 
> > Btw. the syntax worked on linux, but not Windows. 
>
> File descriptors work differently on Windows.  As I said upthread, I 
> was describing a mechanism for Unix.  I don't know how to do this kind 
> of thing on Windows. 
>
>  
Gotcha, thanx! 

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Sending and receiving on file descr other than stdin/out/err

2018-04-20 Thread Ian Lance Taylor
On Fri, Apr 20, 2018 at 7:09 AM, Robert Bielik  wrote:
>>
>> Look at how os.Stdin and friends are initialized in os/file.go.
>> https://golang.org/src/os/file.go#L51 .
>
>
> Hmm... the syscall vars are platform specific. Is there a way to do this
> cross-platform ?
>
> Btw. the syntax worked on linux, but not Windows.

File descriptors work differently on Windows.  As I said upthread, I
was describing a mechanism for Unix.  I don't know how to do this kind
of thing on Windows.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Sending and receiving on file descr other than stdin/out/err

2018-04-20 Thread Robert Bielik

>
>
> Look at how os.Stdin and friends are initialized in os/file.go. 
> https://golang.org/src/os/file.go#L51 . 
>

Hmm... the syscall vars are platform specific. Is there a way to do this 
cross-platform ?

Btw. the syntax worked on linux, but not Windows.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Sending and receiving on file descr other than stdin/out/err

2018-04-20 Thread Robert Bielik
Ok, with the below syntax I managed to write to fd 4, and on the bash cmd 
line do 4>&2 to redirect to stdout. 

/R

Den fredag 20 april 2018 kl. 15:03:41 UTC+2 skrev Robert Bielik:
>
> Exactly how would the call on the child side look ?
>
> file := os.NewFile(uintptr(3), "fd3")
>
> ?
>
> Den fredag 20 april 2018 kl. 14:54:29 UTC+2 skrev Ian Lance Taylor:
>>
>> On Fri, Apr 20, 2018 at 5:22 AM, Robert Bielik  
>> wrote: 
>> > 
>> > I have an application where I'd like to be able to pipe data in/out, 
>> but not 
>> > on stdin/stdout/err, but on other file descriptors. How to ? 
>>
>> If you are on a Unix system, on the parent side see the ExtraFiles 
>> field of os/exec.Command, and on the child side see os.NewFile. 
>>
>> Ian 
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Sending and receiving on file descr other than stdin/out/err

2018-04-20 Thread Ian Lance Taylor
On Fri, Apr 20, 2018 at 6:03 AM, Robert Bielik  wrote:
>
> Exactly how would the call on the child side look ?
>
> file := os.NewFile(uintptr(3), "fd3")
>
> ?

Yes (except that if you use a literal 3 note that Go constants are
untyped so you don't need to use an explicit type conversion to
uinptr).

Look at how os.Stdin and friends are initialized in os/file.go.
https://golang.org/src/os/file.go#L51 .

Ian


> Den fredag 20 april 2018 kl. 14:54:29 UTC+2 skrev Ian Lance Taylor:
>>
>> On Fri, Apr 20, 2018 at 5:22 AM, Robert Bielik 
>> wrote:
>> >
>> > I have an application where I'd like to be able to pipe data in/out, but
>> > not
>> > on stdin/stdout/err, but on other file descriptors. How to ?
>>
>> If you are on a Unix system, on the parent side see the ExtraFiles
>> field of os/exec.Command, and on the child side see os.NewFile.
>>
>> Ian
>
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Sending and receiving on file descr other than stdin/out/err

2018-04-20 Thread Robert Bielik
Exactly how would the call on the child side look ?

file := os.NewFile(uintptr(3), "fd3")

?

Den fredag 20 april 2018 kl. 14:54:29 UTC+2 skrev Ian Lance Taylor:
>
> On Fri, Apr 20, 2018 at 5:22 AM, Robert Bielik  > wrote: 
> > 
> > I have an application where I'd like to be able to pipe data in/out, but 
> not 
> > on stdin/stdout/err, but on other file descriptors. How to ? 
>
> If you are on a Unix system, on the parent side see the ExtraFiles 
> field of os/exec.Command, and on the child side see os.NewFile. 
>
> Ian 
>

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [go-nuts] Sending and receiving on file descr other than stdin/out/err

2018-04-20 Thread Ian Lance Taylor
On Fri, Apr 20, 2018 at 5:22 AM, Robert Bielik  wrote:
>
> I have an application where I'd like to be able to pipe data in/out, but not
> on stdin/stdout/err, but on other file descriptors. How to ?

If you are on a Unix system, on the parent side see the ExtraFiles
field of os/exec.Command, and on the child side see os.NewFile.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.