[Nickle] files not auto-closed on exit?

Bart Massey nickle@nickle.org
Tue, 22 Apr 2003 14:58:40 -0700


The iffy bug is that one expects all files to be closed on
exit, at which point they are synced: I suppose that the
data is stuck in the Nickle heap on exit, having not been
flushed into stdio from whence it would be flushed to the OS
before normal program termination.  The question is whether
Nickle needs to keep a list of all the open files and
install an exit handler...

	Bart

In message <20030422212806.GX28020@sharp.ath.cx> you wrote:
> 
> --JbaLeU65fPBt7QWN
> Content-Type: text/plain; charset=us-ascii
> Content-Disposition: inline
> Content-Transfer-Encoding: quoted-printable
> 
> I have some nickle code that uses fprintf to write to a bunch of
> different files, but at first I got only zero-length files. Bart glanced
> at it and suggested I explicitly close the files, at which point I got
> the output I expected. Bart says this is a bug.
> 
> (Hopefully) relevant excerpts:
> 
> import File;
> void gen_test(file in, file out) {
>     /* ... stuff happens here, then: */
> 
>     for (int i =3D 0; i < 7; i++) {
>         nut x =3D spin_nut(nuts[i], spin[i]);
>         fprintf(in, "%d", x[0]);
>         for (int j =3D 1; j < 6; j++)
>             fprintf(in, " %d", x[j]);
>         fprintf(in, "\n");=20
>     }
>     close(in); /* added */
> 
>     for (int i =3D 0; i < 7; i++)=20
>         fprintf(out, "%d %d\n", i + 1, spin[i] + 1);
>     close(out); /* added */
> }
> 
> for (int i =3D 1; i < 50; i++)
>     gen_test(open(sprintf("In/%d", i), "w"), open(sprintf("Out/%d", i), "w"=
> ));
> 
> exit(0);
> --=20
> Jamey Sharp <jamey@minilop.net> - http://minilop.net/
> 
> --JbaLeU65fPBt7QWN
> Content-Type: application/pgp-signature
> Content-Disposition: inline
> 
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.2.1 (GNU/Linux)
> 
> iD8DBQE+pbPmNgAXSpyH6VcRAhW5AJ0T4RDovnuHtOrtmNivVqMwlkDvxgCdEGe0
> RSiYB3dsZgehFLmiUj4KI5w=
> =Pg9t
> -----END PGP SIGNATURE-----
> 
> --JbaLeU65fPBt7QWN--
> 
> _______________________________________________
> Nickle mailing list
> Nickle@nickle.org
> http://nickle.org/mailman/listinfo/nickle