[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: redirecting output
From: |
Brian |
Subject: |
RE: redirecting output |
Date: |
Thu, 4 Apr 2002 09:26:18 -0600 |
okay, here's what I tried to do
first, in C, I defined a a guile routine that returned the file descriptor
that I want to use:
scm_c_define_gsubr( "get-my-descriptor" , 0, 0, 0, (SCM (*)())
get_my_descriptor);
this just returns a file descriptor to a file that I have already opened so
that I can write log messages out to.
then in a scm file that I load at initialization I tried doing this:
; myinit.scm
(define fd (get-my-descriptor))
(define p (fdes->outport fd))
(display "*** got descriptor ***" p)
(newline p)
(force-output p)
I expected/hoped that the "*** got descriptor***" would be written to the
file that I had previosly opened in my app. But all that happened is my app
app crashed with no signs of my message being written.
One other thing. When I get the file descriptor that my application is
using, it returns 3. Which is the same file descriptor that I see in
scm_fdes_to_port when myinit.scm file is opened. It appears that I have two
different files assigned to the same file descriptor. Why this is or if
it's important, I don't know.
Am I missing something here??
Thanks
Brian
> -----Original Message-----
> From: address@hidden [mailto:address@hidden
> Behalf Of Christopher Cramer
> Sent: Wednesday, April 03, 2002 2:07 PM
> To: Brian
> Cc: address@hidden
> Subject: Re: redirecting output
>
>
> On Wed, Apr 03, 2002 at 01:28:08PM -0600, Brian wrote:
> > I'd like to direct guile output to a known C file descriptor.
> Can this be
> > done??
>
> Use fdopen and set-current-ouput-port. For example:
>
> address@hidden:~$ guile 3> temp.txt
> guile> (set-current-output-port (fdopen 3 "w"))
> guile> (display "hello there") (newline)
> guile> (quit)
> address@hidden:~$ cat temp.txt
> #<output: standard output /dev/pts/1>
> hello there
> address@hidden:~$
>
> --
> Christopher Cramer <address@hidden> <http://www.pyro.net/~crayc/>
> Quoi que vous fassiez, écrasez l'infâme, et aimez qui vous aime.
> -- Voltaire
>
> _______________________________________________
> Guile-user mailing list
> address@hidden
> http://mail.gnu.org/mailman/listinfo/guile-user
>