Re: mc sets process group differently from shell; forgets to close fd# 3
- From: Pavel Tsekov <ptsekov gmx net>
- To: Denis Vlasenko <vda linux googlemail com>
- Cc: MC dev <mc-devel gnome org>, slang-users-l jedsoft org
- Subject: Re: mc sets process group differently from shell; forgets to close fd# 3
- Date: Sat, 21 Apr 2007 00:29:59 +0300 (EEST)
On Fri, 20 Apr 2007, Denis Vlasenko wrote:
Hi mc people,
If you compile and run the following program
under shell and under mc...
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
int i, numfd = open("/dev/null", O_RDONLY);
printf("pid=%d\n", getpid());
printf("ppid=%d\n", getppid());
printf("tty_pgrp=%d\n", (int)tcgetpgrp(0));
printf("task_pgrp=%d\n", (int)getpgrp());
for (i = 0; i < numfd; i++) {
printf("fd# %d: '%s'\n", i, ttyname(i));
}
return 0;
}
you will see the following:
bash-3.2# ./z
pid=8183
ppid=8181
tty_pgrp=8183 <========== child is in its own process group
task_pgrp=8183 <==========
fd# 0: '/dev/pts/4'
fd# 1: '/dev/pts/4'
fd# 2: '/dev/pts/4'
bash-3.2# echo $$ ; exec mc
8181
# ./z
pid=8212
ppid=8181
tty_pgrp=8181 <========== child is in mc's process group
task_pgrp=8181 <========== child is in mc's process group
fd# 0: '/dev/pts/4'
fd# 1: '/dev/pts/4'
fd# 2: '/dev/pts/4'
fd# 3: '/dev/tty' <=== ??!
[...]
Big one (actually, I think it's a bug): stray fd# opened
to controlling terminal.
The descriptor to /dev/tty is created by S-Lang in SLang_init_tty().
Maybe it would make sense to mark it FD_CLOEXEC ?
Thanks!
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]