[BusyBox] bug#1261: BusyBox] bug#1261: Ash holds some extra file descriptors open
Vladimir N. Oleynik
dzo at simtreas.ru
Mon Aug 12 00:46:03 UTC 2002
Hi, Steve.
> > I not found other opened fd except 0-2 :0
>
> I take it you compiled this program and ran it as a child process to
> look at the open fds?
Yes.
> You won't see it there, as you have found.
>
> Instead, you have to look at the kernel to see who's holding what
> open.
I rewrote your test and change all "cat" usage to "help" - builting
function ash and hack this with usage my fd_test with your algoritm:
#if DEBUG == 2
static void test_fd (void)
{
int p, l, i;
FILE *log;
static const char nlog[]="/tmp/fd_opened.log";
char cmd[256];
log = fopen(nlog, "a");
if(log==NULL) {
fprintf(stderr, "can`t create %s\n", nlog);
return;
}
p = getpid();
strcpy(cmd, "/proc/");
l = strlen(cmd);
sprintf(cmd+l, "%d/fd/", p);
l = strlen(cmd);
fprintf(log, "pid=%d test opened fd\n", p);
for(i=0; i<1024; i++) {
if(i==fileno(log))
continue;
sprintf(cmd+l, "%d", i);
if(access(cmd, F_OK)==0)
fprintf(log, "pid=%d opened fd=%d\n", p, i);
}
fclose(log);
}
#endif
I see open 3, 10, 11 fd now. :(
But ash have deferent tread call external and internal process.
> The rules for redirection are: pipes are done first, then redirections
> are done in order from left to right.
>
> Here's a bit of command line to explain:
> you will find that stderr goes to log2 as you intend, and again, bash
> doesn't pause but busybox ash does.
>
> Does that help?
Thanks.
Ok. Ok. Ok.
I begining porting ash 0.3.8-38 (last debian ash) to busybox.
All ported done, but all my and other optimizations changes not ready.
Please wait 1-2 week.
--w
vodz
More information about the busybox
mailing list