#include "sftest.h" /* test to see if files created in atexit functions work ok */ void ae() { Sfio_t* f = sfopen(NIL(Sfio_t*), tstfile(0), "w"); if(!f) terror("Can't create file"); if(sfwrite(f,"1234\n",5) != 5) terror("Can't write to file"); } #if __STD_C main(int argc, char** argv) #else main(argc, argv) int argc; char** argv; #endif { Sfio_t* f; if(argc <= 1) /* atexit function registered after some sfio access */ { if(!(f = sfopen(NIL(Sfio_t*), tstfile(1), "w")) ) terror("Can't create file"); if(sfwrite(f,"1234\n",5) != 5) terror("Can't write to file"); atexit(ae); system(sfprints("%s 1",argv[0])); } else /* atexit function registered before some sfio access */ { atexit(ae); if(!(f = sfopen(NIL(Sfio_t*), tstfile(1), "w")) ) terror("Can't create file"); if(sfwrite(f,"1234\n",5) != 5) terror("Can't write to file"); } exit(0); }