On Fri, Jul 22, 2011 at 9:48 AM, Mark Dootson <mark.doot...@znix.com> wrote: > So, the int / file descriptor we pass to close() is being interpreted as > invalid.
Got it: the code for the first file written from boot.c does a second close() on an already closed file descriptor: i = my_mkfile( argv[0], stmpdir, par_basename(par_findprog(argv[0], strdup(par_getenv("PATH")))), size_load_my_par, &my_perl ); if ( !i ) return 2; if ( i != -2 ) { if (write_chunks(chunks_load_my_par, i) || close(i)) return 2; close(i); <------------ delete this line chmod(my_perl, 0755); write_chunks(...) returns 0 on success, so next expression in || will be evaluated. close(i) (first call) succeeds, i.e. returns 0, hence if condition is not satisfied and we proceed to call close(i) again.... This code is horribly warped. Cheers, Roderich