[Tutor] exec vs system (fwd)

Viktor Lakics lakicsv@usa.net
Mon, 26 Feb 2001 23:27:45 +0000


On Sun, Feb 25, 2001 at 06:50:45PM -0500, D-Man wrote:
> I don't think it makes any difference.  If you run fetchmail in daemon
> mode from the command line, your shell returns to an interactive state
> immediately (after reporting the PID of the fetchmail daemon).  The
> way fetchmail works (basically), if you start it in daemon mode is :
> 
> 
> pid = fork()
> if pid == 0 :
>     # this is the child,
>     while 1 :
>         get_mail()
>         sleep( 1000 )
> else :
>     # this is the original parent, 
>     # return control back to the previous process (shell, whatever)
>     sys.exit( 0 )
> 
> 
> 
> If your script simply invokes fetchmial using os.system, you will get
> the success exit value almost immediately, while the deamon runs in
> the background and your script is free to terminate the python
> interpreter at its leisure.  If you use execv, the interpreter will be
> replaced by fetchmail, which will fork and then terminate the parent
> process.
> 
> You can also start fetchmail in daemon mode by specifying it in your
> fetchmailrc file.

Thanks for the info...

 
> I don't know if this is relevant/helpful at all, but I simply put
> "fetchmail" in my .bash_profile file so that fetchmail is run when I
> login.  I put "fetchmail --kill" (or whatever the option is, I'm not
> at my linux box right now) in my .logout file so that it terminates
> when I log out.  I can also run fetchmail at any time since it will
> check for an already running daemon and simply wake it up if it
> exists.

What I usually do (and this was the point of writing the script) is
to have fetchmail -d in my /etc/ppp/ip-up.local, so every time I
dial into my isp my mail is downloaded. But I want to read my email
at work, even when someone at home connets to browse the internet. So
on weekdays between 8 to 6 PM my mail is not automatically
downloaded, any other time it is... 

Viktor