--- src/bin/rm/rm.c 2005/01/05 16:24:19 1.11 +++ src/bin/rm/rm.c 2005/06/03 16:00:23 1.12 @@ -39,6 +39,7 @@ #include #include #include +#include #include #include @@ -74,6 +75,7 @@ main(int argc, char *argv[]) { int ch; const char *p; + pid_t tty_pgrp; /* * Test for the special case where the utility is called as @@ -110,7 +112,15 @@ main(int argc, char *argv[]) iflag = 1; break; case 'I': - Iflag = 1; + /* + * The -I flag is intended to be generally aliasable + * in /etc/csh.cshrc. We apply it only to foreground + * processes. + */ + if (ioctl(0, TIOCGPGRP, &tty_pgrp) == 0) { + if (tty_pgrp == getpgrp()) + Iflag = 1; + } break; case 'P': Pflag = 1;