[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Q] HOWTO redirect a i/o-port in Unix??
Quoting Matthew Flatt:
> That seems very strange, and not right. I'm looking into it.
The problem is related to the fact that `process[*]' is implemented via
fork() within MzScheme. The forked process inherits a copy of each file
descriptor open by MzScheme at the time; most of them need to be
closed, especially descriptors that are pipes to other processes.
I can't explain why I never encountered this simple problem when using
MzScheme to create pipelines before. Anyway, it will be fixed in the
next release.
A brute-force fix is to replace
/* Close unwanted descriptors */
MSC_IZE(close)(to_subprocess[0]);
MSC_IZE(close)(to_subprocess[1]);
MSC_IZE(close)(from_subprocess[0]);
MSC_IZE(close)(from_subprocess[1]);
MSC_IZE(close)(err_subprocess[0]);
MSC_IZE(close)(err_subprocess[1]);
in port.c with
for (i = 3; i < 256; i++)
close(i);
where 256 is replaced with the maximum number of file descriptors
allowed per process on your system.
Matthew