Re: How to catch *** - EVAL: User break?

Alberto Riva <[email protected]>
Newsgroups gmane.lisp.clisp.general
Message-ID <[email protected]>
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...

Alberto



> #!/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))
> (shell "/home/data1/protected/bin/CRM/LG-ProcessRemoteLeads-yaml.pl /home/data1/protected/.business-global.yml")
> (shell "/home/data1/protected/bin/CRM/Mailing.pl continue")
> (close lock-file)
> (delete-file lock-file)
>
>
>
> ----- 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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.