From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96079072816123.tru64-unix-managers.marc@archive.invalid> From: managers account Date: Thu, 16 Sep 1999 08:44:00 +0000 To: tru64-unix-managers Subject: SUMMARY FOLLOWUP - forced umount X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96079072816123 So many requests have been received for the fuser program to use on 4.0b an the script that I am following up by posting them here for the archive. stuart mckenzie >From kazuro.furukawa@kek.jp Thu Sep 16 09:22:53 1999 On 4.0B fuser(2) was available. I attached a message which have simple program to list PID's using fuser(2). You may modify this to kill them. /* * fuser - Reports PIDs and UIDs for files, file systems and/or the devices attached to them. * This is so simple it makes you wonder why DEC didn't bother to do it themselves. * * Produced at Pacific Star Communicatons * * History : * 31/12/95 J.Rouse Initial version * 31/12/95 D.Bock Added in flags for process type. */ #include #include #include #include main(argc,argv) int argc; char **argv; { char *file; f_user_t fuser_array[10000]; /* Arbitrary array size */ int i,fuser_count=0; if ( argc != 2 ) { printf("Usage: fuser FILE\n"); exit(1); } file = argv[1]; /* No buffering */ setbuf(stdout,NULL); fuser_count=fuser(file, 0l, fuser_array, (long) sizeof (fuser_array)); if ( fuser_count <0 ){ exit (1); } else { printf("%s:\n",file); if (fuser_count > 0 ){ for ( i=0; i < fuser_count; i++){ printf("%d", fuser_array[i].fu_pid); if (fuser_array[i].fu_flags & (F_CDIR|F_RDIR)) printf("c"); else if (fuser_array[i].fu_flags & (F_PDIR)) printf("p"); else if (fuser_array[i].fu_flags & (F_TTY)) printf("t"); else if (fuser_array[i].fu_flags & (F_TRACE)) printf("tr"); printf(" "); }; }; printf("\n"); } exit(0); } And the script approach: >From Davis@Tessco.Com Thu Sep 16 09:23:11 1999 Here is a sample of script that does something similar to what you want. You probably can't use this as-is, you'll need to re-write it or adapt it for your needs. kill_proc_on () { # stop processes with open files. ${BINDIR}/bin/fuser -ck $* } nfs_wait_loop () { # function, to wait for a clean umount of mount points # parameters proc_string, interval proc_string=$1; interval=$2; is_running=0 while [ $is_running -eq 0 ] do mount | grep -w "$proc_string" | grep -v grep is_running=$? if [ $is_running -eq 1 ] then break else /sbin/umount -f $proc_string kill_proc_on $proc_string sleep $interval is_running=0 fi done }