Subject: Read-only mode

From: Matt Simmons <[email-masked]>
Date: Tue, 5 Oct 1993 11:25:48 -0500 (CDT)

Starting pine, ^Zing it to go do something else, and then 
forgetting about the ^Z'd process until you try to start up pine again, 
and then having to wait for it to try to talk to the other process only 
to find that it can't and that both are RO and having to kill both is 
rather annoying....  Could pine be fixed so that if it opens up and 
notices that another pine is running, it asks if it can make the other 
one RO?  This would save a lot of grief...

---

From: Mark Crispin <[email-masked]>
Date: Tue, 5 Oct 1993 22:47:47 -0700 (PDT)

> one RO?  This would save a lot of grief...

We agree that this is annoying, but none of the various alternatives which we
have considered have been any better.  We'll look into this further, but for
the time being the best thing is to avoid suspending Pine and forgetting about
it!

-- Mark --

---

From: Alex Tang <[email-masked]>
Date: Wed, 6 Oct 1993 08:47:58 -0400 (EDT)

> the time being the best thing is to avoid suspending Pine and forgetting about

I also wrote about this...I was wondering if it's possible to get the second
pine session to see if the first is sleeping.  If so, then make the second
pine session read only automatically and not try to grab the lock.

just wondering....

...alex...

Alex Tang  ---  [email-masked][email-masked]
-----------+    U of M, SNRE: Student and Computer Consultant II,
PGP on req.|    ITD/CSS Consultant, Short asian with long hair :)
or finger  |

---

From: Muriel McKay <[email-masked]>
Date: Wed, 6 Oct 1993 10:17:44 -0400 (EDT)

John Benjamins at McMaster renamed pine to pine.exe and then wrote this
script which he called pine . This checks for an existing pine process and
if it finds one asks very nicely if it should be killed (mcmail is the
name of our mail machine.) This works on SGI - Irix 4.0.5 . I'm sure I have
one for sun 4.1.2 . I'll look and post later if anyone wants. 

Muriel McKay,
Analyst, Desktop Computing Support.
CIS.  ABB132 ext. 23630 McMaster University . Hamilton Ontario, Canada.

--------------------------------------------------------------------------

#!/usr/bin/perl -P-   # -*-Perl-*-

# Set up variables

$Answer = not;
$Continue = not;
$Kill = no;
$User = $ENV{'USER'} || $ENV{'LOGNAME'} || (getpwuid($<))[0];
$LockFile = "/tmp/\.\\usr\\mail\\".$User;
$RealPine = "/usr/local/pine/bin/pine.exe";

open(TTYIN, "</dev/tty") || die "can't read /dev/tty: $!";
open(TTYOUT, ">/dev/tty") || die "can't write /dev/tty: $!";
select(TTYOUT);
$| = 1;
select(STDOUT);

# Handle signals

$SIG{'INT'} = 'IGNORE';
$SIG{'TERM'} = 'IGNORE';
$SIG{'TSTP'} = 'IGNORE';
$SIG{'HUP'} = 'cleanup';

sub ignore {
    print "\nUnknown command\n\n";
}

sub cleanup {
    system "stty", 'icanon';
    system "stty", 'isig';
    system "stty", 'echo';
    system "stty", 'eol', '^@';
}

#

system "stty", '-icanon';
system "stty", '-isig';
system "stty", '-echo';
system "stty", 'eol', '^A';

# Look for the pine lock file in /tmp

if ( -f "$LockFile" ) {
    while ( $Answer eq 'not' ) {
        print TTYOUT "\
You have another copy of pine running.  This may be the result of rebooting \
your PC while you were logged in to mcmail.  In any case, do you want to kill \
the other session and start a new one? [y/n]: ";
        read(TTYIN, $Answer, 1);
        if ($Answer =~ /^y/i) { 
            print TTYOUT "\n";
            $Kill="yes"; 
	}
        elsif ($Answer =~ /^n/i) {
            while ($Continue eq 'not') {
                print "\n\
******** WARNING ******** WARNING ******** WARNING ******** WARNING ********\
\
Pine will now start in READ ONLY mode.  This means you will not be able to
change your inbox folder.  Are you sure you want to do this? [y/n]: ";
		read(TTYIN, $Continue, 1);
		print TTYOUT "\n";
                if ($Continue =~ /^y/i) {
                    &cleanup;
		    exec $RealPine, @ARGV;
		    die "Can't run $RealPine: $!";
		}
                elsif ($Continue =~ /^n/i) {
		    &cleanup ; exit;
		}
                elsif ($Continue =~ /^q/i) {
		    &cleanup ; exit;
		}
		else {
		    print TTYOUT "\nPlease answer with y or n only please\n";
                    $Continue="not";
		}
	    }
	}
	elsif ($Answer =~ /^q/i) {
	    &cleanup ; print "\n" ; exit;
	}
	else {
            print TTYOUT "\n\nPlease answer with y or n only please\n\n";
            $Answer="not";
	}
    }
}

# Kill the old one?

if ( $Kill eq "yes" ) {
    system '/etc/fuser', '-k', $LockFile;
}

&cleanup;

# If we get here, we want to start the real Pine executable

exec $RealPine, @ARGV;
die "Can't run $RealPine: $!";