octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wait_for_file ?? [GL2PS error: Bad file pointer]


From: Ben Abbott
Subject: Re: wait_for_file ?? [GL2PS error: Bad file pointer]
Date: Mon, 13 Sep 2010 18:54:19 -0400

On Sep 12, 2010, at 12:20 AM, Shai Ayal wrote:

> On Sun, Sep 12, 2010 at 2:42 AM, Michael D Godfrey
> <address@hidden> wrote:
>> On 09/11/2010 03:00 PM, Ben Abbott wrote:
>> 
>> to use, pass the fid as a string to drawnow:
>>> e.g. to keep current functionality, use
>>> fid = fopen ("test.eps","wb");
>>> drawnow ("eps" , sprintf ("%d" , fid));
>>> 
>>> and to pipe it into another program, use popen:
>>> fid = popen ("cat >  test.eps" , "w")
>>> drawnow ("eps" , sprintf ("%d" , fid));
>>> 
>>> Shai
>> 
>> I'm seeing a repeatable error/warning when printing to a file.
>> 
>> The code below ...
>> 
>> Ben,
>> 
>> I see what Shai said above, but I could not find where he does an
>> fclose in drawnow().   By the way, it is always good practice to follow
>> fclose(fid); with fid =0;  . fclose() does not change the fid, and in fact
>> you can still do IO using that fid, but which file it points to will change
>> as more fopens are done!  Another benefit of C and its IO libraries.
>> 
> fclose is in glps-renderer::draw which IMHO is the only place it
> should be since it's the only place guaranteed to be after the file
> has been written to.
> 
> Shai

Shai,

I'm unable to get writing to files to work with GL2PS. I continue to get the 
error, "GL2PS error: Bad file pointer".

However, I did find an approach that eliminates all errors with pipes. I don't 
understand why this works for gl2ps, but when I add *both* the waitpid() and 
pclose(pid), then I get no errors.

        pid = popen ("cat > test.eps", "w");
        drawnow ("eps" , sprintf ("%d" , pid));
        waitpid (pid);
        pclose (pid);

I have a few more changes to make to the printing  routines. With some luck 
I'll post another proposed changeset this evening.

Ben



reply via email to

[Prev in Thread] Current Thread [Next in Thread]