Re: How to catch *** - EVAL: User break?
Jean Louis <[email protected]>
| Newsgroups | gmane.lisp.clisp.general |
|---|---|
| Message-ID | <[email protected]> |
Oh thank you.
On Tue, Nov 22, 2016 at 10:45:21AM -0500, Alberto Riva wrote:
> On 11/22/2016 08:27 AM, Jean Louis wrote:
> >
> >
> > Hello,
> >
> > I am trying to convert my thinking from Perl to Common Lisp, CLISP
> > implementation.
> >
> > And I have noticed that if I interrupt this execution, the lock file
> > is going to stay there forever.
> >
> > I can see error message:
> >
> > *** - EVAL: User break
> >
> > How can I prevent that break (CTRL-C) so that I execute some finished
> > removals of the lock file, before the program is stopped?
>
> See UNWIND-PROTECT. The general form is:
>
> (unwind-protect
> (main-form)
> (cleanup-form1 ...)
> (cleanup-form2 ...))
>
> The cleanup forms will be executed after main-form, even if execution of
> main-form is interrupted (unless the whole lisp process dies for some
> reason that can't be handled).
>
> Note that this is a Common Lisp question more than a CLISP question...
Thank you, I have got it working now, if I interrupt it, it deletes
the lock file.
Jean
#!/usr/bin/clisp -q -norc
(defparameter lock-file "/tmp/Crontab.lock")
(when (probe-file lock-file) (princ "Process is already running.") (exit 1))
(setf lock-file (open lock-file :if-does-not-exist :create))
(defun exit-lock ()
(close lock-file)
(delete-file lock-file))
(defun get-leads ()
(shell
"/home/data1/protected/bin/CRM/LG-ProcessRemoteLeads-yaml.pl /home/data1/protected/.business-global.yml"))
(defun send-emails ()
(shell "/home/data1/protected/bin/CRM/Mailing.pl continue"))
(unwind-protect
(progn (get-leads)
(send-emails))
(exit-lock))
> > ----- End forwarded message -----
> >
> > ------------------------------------------------------------------------------
> > _______________________________________________
> > clisp-list mailing list
> > [email protected]
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.sourceforge.net_lists_listinfo_clisp-2Dlist&d=DQICAg&c=qS4goWBT7poplM69zy_3xhKwEW14JZMSdioCoppxeFU&r=5jFcOGd-MvIv35xMJiuGPg&m=MMrqiY7J4__OLxdcXan85B0ADYk89hMaVptdQRgTJBY&s=-oqZ-sUAtfsq2fYBD3p1NYFLOMen-BZD9qBWXRja-Ms&e=
> >
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> clisp-list mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/clisp-list
------------------------------------------------------------------------------
_______________________________________________
clisp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/clisp-list