mc sets process group differently from shell; forgets to close fd# 3
- From: Denis Vlasenko <vda linux googlemail com>
- To: mc-devel gnome org
- Subject: mc sets process group differently from shell; forgets to close fd# 3
- Date: Fri, 20 Apr 2007 21:42:07 +0200
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' <=== ??!
Note that there are two differences, one minor and one pretty big.
Small one: child process is not given its own porcess group when run
under mc, while under sh it is. It means that if child will create its
own process group by itself and then die, under shell it works but
under mc mc will auto-background itself on child's death,
because tty's pgrp will not match mc's. Nasty.
Big one (actually, I think it's a bug): stray fd# opened
to controlling terminal.
mc version 4.6.0, compiled without subshell support.
--
vda
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]