SCM_DEFINE (scm_close_all_fdes_except, "close-all-fdes-except", 0, 0, 1, (SCM fdes_list), "Close all file descriptors for ports used by the interpreter\n" "except for those supplied as arguments. This procedure\n" "is intended to be used before an exec(2) call. The related\n" "procedure @code{close-all-ports-except} is unsuitable for that\n" "because it flushes port buffers.") #define FUNC_NAME s_scm_close_all_fdes_except { int i, sysrv; SCM_VALIDATE_REST_ARGUMENT (fdes_list); for (i = 0; i < scm_port_table_size; i++) { SCM thisport = scm_port_table[i]->port; SCM ls = fdes_list; int matchp = 0; SCM fd; if (! SCM_OPFPORTP (thisport)) continue; fd = scm_fileno (thisport); while (SCM_NNULLP (ls) && !matchp) { if (SCM_EQ_P (SCM_CAR (ls), fd)) { /* This used to simply goto next_port, but gcc 3.3.2 warns "deprecated use of label at end of compound statement". The march of progress and all that. */ matchp = 1; break; } ls = SCM_CDR (ls); } if (!matchp) { SCM_SYSCALL (sysrv = close (SCM_INUM (fd))); if (sysrv < 0) SCM_SYSERROR; } /* next_port: */ } return SCM_UNSPECIFIED; } #undef FUNC_NAME