Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Two pine processes at once? Ugh!

0 views
Skip to first unread message

Buzzard

unread,
May 19, 2009, 6:32:24 AM5/19/09
to

Running pine 4.64 on debian linux 4.0, but probably that's not too important;
my question is much more basic than this.

Occasionally I fire up pine in a shell window when I have a pine process
running already; such things happen. The moment I do this, in my current
set-up, the new pine process attempts to take charge and disable
the old one as much as possible---it wants the old one to become
read-only etc etc, which is sensible because I shouldn't think you
want pines writing to one mail folder.

But sometimes this fails, or at least has unfortunate side-effects---e.g. if
I have suspended a pine process then start a second one, then the
second one might spend a long time trying to get a response from
the first, during which the second process is unresponsive etc etc.
Not much fun.

Over the years I have come to realise that 99.9 percent of the
time, when I fire up a second pine process with one running already,
it is an oversight on my part, rather than a carefully-planned idea.
So I'd like to change the default! When I fire up a second pine process,
I don't want it to try and wrest control of my mailbox folders from
the first one, I want it to start up crippled---i.e. the *second*
process should be read-only---or perhaps not even start up at all!
("There is already a pine process running: sort yourself out buster
and then get back to me coz I ain't starting another one unless you beg"
sort of thing).

Is this easy to do?

buzzard

Lucas Levrel

unread,
May 19, 2009, 8:41:32 AM5/19/09
to
Le 19 mai 2009, Buzzard a écrit :

> So I'd like to change the default! When I fire up a second pine process,
> I don't want it to try and wrest control of my mailbox folders from
> the first one, I want it to start up crippled---i.e. the *second*
> process should be read-only---or perhaps not even start up at all!
> ("There is already a pine process running: sort yourself out buster
> and then get back to me coz I ain't starting another one unless you beg"
> sort of thing).

For that second way, you may use this small shell script:
ps -u yourloginhere | grep pine -q || pine
which will start pine if there's not another one, or do nothing. If you do
want some error message then, get back to me.

--
LL

John Mayson

unread,
May 19, 2009, 10:05:19 AM5/19/09
to
On Tue, 19 May 2009, Lucas Levrel wrote:

> For that second way, you may use this small shell script:
> ps -u yourloginhere | grep pine -q || pine
> which will start pine if there's not another one, or do nothing. If you do
> want some error message then, get back to me.

Would that work? Wouldn't the grep command itself appear with pine
causing the program not to run? I would try this...

ps -u login | grep -v grep | grep pine -q || pine

I haven't tested the above line.

John

--
John Mayson <jo...@mayson.us>
Austin, Texas, USA

Buzzard

unread,
May 19, 2009, 10:21:31 AM5/19/09
to
John Mayson <jo...@mayson.us> wrote:

> Would that work?

I tried it and it did, but I don't quite understand why.

ps auxww | grep pine

finds "grep pine"

but

ps -u buzzard | grep pine

doesn't. It might be a race condition though, i.e. it might occasionally
not work.

> I would try this...
>
> ps -u login | grep -v grep | grep pine -q || pine

Another problem with both suggestions is that now "pine user@hostname"
doesn't do what you want it to do; this can be fixed with a careful $@.

I asked the question here because I was expecting a "pine" solution.
I got a "unix" solution instead, but that's good enough for me. In
fact I just wrote my own shell script, which has held up so far:

$ cat ~/bin/pine
if (ps -u buzzard | grep pine -q) then
echo "pine already running?"
ps auxww | grep pine | grep -v grep;
else
pine $@;
fi

$

Note that I use grep -v once but not twice, indicating that I don't
really understand what's going on :-)

buzzard

Lucas Levrel

unread,
May 20, 2009, 6:15:34 AM5/20/09
to
Le 19 mai 2009, Buzzard a écrit :

> John Mayson <jo...@mayson.us> wrote:
>
> > Would that work?
>
> I tried it and it did, but I don't quite understand why.
>
> ps auxww | grep pine
>
> finds "grep pine"
>
> but
>
> ps -u buzzard | grep pine
>
> doesn't. It might be a race condition though, i.e. it might occasionally
> not work.

Your remark made me wonder also, because occasionally when I grep to find
process foo I get that "grep foo" line. Looking at the man gives the
answer: ps -u username displays only process names, not full command line.
Thus, not the arguments of grep:

coulomb:~> ps -u lucas |grep pine
4471 pts/0 00:00:02 pine
coulomb:~> ps -fu lucas |grep pine
lucas 4445 1 0 09:27 ? 00:00:06 gnome-terminal --window-with-profile=mail --geometry=82x24-0-0 -x pine -i -passfile /home/lucas/pine/passfile
lucas 4471 4445 0 09:27 pts/0 00:00:02 pine -i -passfile /home/lucas/pine/passfile
lucas 11588 4485 0 12:08 pts/2 00:00:00 grep pine

More fun:

coulomb:~> ps -u lucas |grep grep
11641 pts/2 00:00:00 grep
coulomb:~> ps -fu lucas |grep grep
lucas 11843 4485 0 12:14 pts/2 00:00:00 grep grep

;-)
--
LL

Andre van Eyssen

unread,
May 24, 2009, 5:07:16 AM5/24/09
to
On 2009-05-19, John Mayson <jo...@mayson.us> wrote:

> Would that work? Wouldn't the grep command itself appear with pine
> causing the program not to run? I would try this...
>
> ps -u login | grep -v grep | grep pine -q || pine
>
> I haven't tested the above line.

Good lord! The followups on this are scary, too.

I'm pretty sure that Linux has pgrep now, and if it runs anything like
Solaris,

pgrep -u $USER pine || pine

or, crank it along the lines of

pgrep -u $USER pine && echo "Pine already running." || pine

--
Andre van Eyssen.
mail: an...@purplecow.org jabber: an...@interact.purplecow.org
purplecow.org: UNIX for the masses http://www2.purplecow.org
purplecow.org: PCOWpix http://pix.purplecow.org

0 new messages