Subject: Re: FVWM: init-function

From: Rainer Koehler <[email-masked]>
Date: Wed, 3 Dec 2003 19:18:11 +0100 (CET)

The first time in months I can answer a question here, and Dan is
quicker... ;-)

Dan Espen writes:

> Tobias Werth <[email-masked]> writes:
>> Hi,
>> 
>> in my .fvwm2rc I have inserted an Init Function as follows:
>> 
>> AddToFunc InitFunction
>> + I Exec exec ssh-add < /dev/null
>> + I Exec exec $HOME/bin/email-notify
>> 
>> 
>> Both programs grab for the keyboard with ssh-askpass and one of it fails.
>> Can I give some option to the Init Function, so that the commands are process
>> ed sequentially?

> Exec exec sh -c 'ssh-add < /dev/null;$HOME/bin/email-notify'

Isn't it a bit overkill to let fvwm start a shell, just to exec sh?
I have something similar to

  Exec ssh-add < /dev/null;$HOME/bin/email-notify

in my .fvwmrc and it works perfectly (with different commands, but
still requiring execution in one shell).

By the way, I thought the double-exec was obsolete for years, but the
manpage of my fvwm still mentions it.  So, what is the current status?

Rainer

PS: Tobias, the mail to you was meant for the list, sorry.

PPS: Dan, the mail for you was meant for the list, too.  I should
     really look at the header more carefully...
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].

---

From: Dan Espen <[email-masked]>
Date: Wed, 03 Dec 2003 13:34:12 -0500

> The first time in months I can answer a question here, and Dan is

Sorry.

> >> Can I give some option to the Init Function, so that the commands are
> >> processed sequentially?
> 

The double exec is to get rid of the shell that launches and
waits for the
the command to terminate.
Since email-notify probably hangs around, Exec exec is probably
better, but I'm not too sure that the shell I created with 'sh -c'
isn't hanging around.  Probably another exec in the command
will deal with it.

All in all, I like your suggested solution better.
I'll take simple over efficient every time.

> manpage of my fvwm still mentions it.  So, what is the current status?

       Exec command
              ... You
              probably want to use an additional "exec" at
              the beginning of command.  Without that, the
              shell  that fvwm invokes to run your command
              stays until the command exits.   In  effect,
              you'll  have twice as many processes running
              as you need.   Note  that  some  shells  are
              smart  enough  to  avoid  this, but it never
              hurts to include the "exec" anyway.

-- 
Dan Espen                           E-mail: [email-masked]

---

From: "Paul Smith" <[email-masked]>
Date: 03 Dec 2003 15:08:39 -0500

>> Exec ssh-add < /dev/null;$HOME/bin/email-notify

  de> The double exec is to get rid of the shell that launches and waits
  de> for the the command to terminate.  Since email-notify probably
  de> hangs around, Exec exec is probably better, but I'm not too sure
  de> that the shell I created with 'sh -c' isn't hanging around.
  de> Probably another exec in the command will deal with it.

  de> All in all, I like your suggested solution better.
  de> I'll take simple over efficient every time.

If you can stand being a _little_ less simple to get a _little_ more
efficient, I think what you really want is this:

  Exec ssh-add < /dev/null ; exec $HOME/bin/email-notify

This way (a) a shell is invoked, (b) the shell runs ssh-add, then (c)
the shell execs email-notify, and in the end you just have one
email-notify process running.

  >> > Exec exec sh -c 'ssh-add < /dev/null;$HOME/bin/email-notify'

This doesn't save anything over the version at the top of this email, in
terms of # of processes.

Fvwm starts a shell, then that shell exec's a new shell, then the second
shell starts ssh-add, then the second shell starts email-notify.

So, at the end you still have a shell and email-notify running, same as
the simple method :).

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <[email-masked]>   HASMAT--HA Software Mthds & Tools
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
-------------------------------------------------------------------------------
   These are my opinions---Nortel Networks takes no responsibility for them.
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to [email-masked].
To report problems, send mail to [email-masked].