1 Return-Path: <tomi.ollila@iki.fi>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 561A3431FD0
\r
6 for <notmuch@notmuchmail.org>; Sat, 11 Jan 2014 10:50:20 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id 6ixgn8U851wQ for <notmuch@notmuchmail.org>;
\r
16 Sat, 11 Jan 2014 10:50:08 -0800 (PST)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id BB955431FC3
\r
19 for <notmuch@notmuchmail.org>; Sat, 11 Jan 2014 10:50:08 -0800 (PST)
\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])
\r
21 by guru.guru-group.fi (Postfix) with ESMTP id B5A9610005E;
\r
22 Sat, 11 Jan 2014 20:50:00 +0200 (EET)
\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
24 To: David Bremner <david@tethera.net>, notmuch@notmuchmail.org
\r
25 Subject: Re: [PATCH] test/emacs: replace the use of process-attributes with
\r
27 In-Reply-To: <1389461139-20249-1-git-send-email-david@tethera.net>
\r
28 References: <m2bnziygdu.fsf@guru.guru-group.fi>
\r
29 <1389461139-20249-1-git-send-email-david@tethera.net>
\r
30 User-Agent: Notmuch/0.17+23~ga575e35 (http://notmuchmail.org) Emacs/24.3.1
\r
31 (x86_64-unknown-linux-gnu)
\r
32 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
33 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
34 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
35 Date: Sat, 11 Jan 2014 20:50:00 +0200
\r
36 Message-ID: <m2txda5p5z.fsf@guru.guru-group.fi>
\r
38 Content-Type: text/plain
\r
39 X-BeenThere: notmuch@notmuchmail.org
\r
40 X-Mailman-Version: 2.1.13
\r
42 List-Id: "Use and development of the notmuch mail system."
\r
43 <notmuch.notmuchmail.org>
\r
44 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
45 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
46 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
47 List-Post: <mailto:notmuch@notmuchmail.org>
\r
48 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
49 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
50 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
51 X-List-Received-Date: Sat, 11 Jan 2014 18:50:20 -0000
\r
53 On Sat, Jan 11 2014, David Bremner <david@tethera.net> wrote:
\r
55 > In some environments (at least Hurd), process-attributes is
\r
56 > unimplimented and always returns nil. This ends up causing test
\r
57 > failures (see e.g. id:87a9ffofsc.fsf@zancas.localnet).
\r
59 > Historically and according to POSIX 1003.1-2001, a signal of 0 can be
\r
60 > used to check the validity of a pid. This seems less heinous than
\r
61 > parsing the output of ps(1).
\r
64 > Thanks to Domo for the simpler solution. Now that I think about it,
\r
65 > perhaps this makes sense as a debian only update, since it currently
\r
66 > fails only on Debian/Hurd, which according to the GNU project is the
\r
67 > only "working distribution
\r
69 Would an ultimate(tm) solution be:
\r
71 (defun orphan-watchdog (pid)
\r
72 "Initiate orphan watchdog check."
\r
74 (if (process-attributes pid)
\r
75 (lambda (pid) (if (not (process-attributes pid) (kill-emacs))))
\r
76 (lambda (pid) (if (/= 0 (signal-process pid 0)) (kill-emacs))))
\r
79 of course the lambdas can be replaced w/ symbols to functions, just
\r
80 compressed for this example -- also w/ appropriate commit messages...
\r
82 This could work on unices, hurd, windows, whatnot...
\r
85 Anyway, the current patch also LGTM.
\r
90 > test/test-lib.el | 15 +++++++++------
\r
91 > 1 file changed, 9 insertions(+), 6 deletions(-)
\r
93 > diff --git a/test/test-lib.el b/test/test-lib.el
\r
94 > index d26b49f..37fcb3d 100644
\r
95 > --- a/test/test-lib.el
\r
96 > +++ b/test/test-lib.el
\r
97 > @@ -77,19 +77,22 @@ invisible text."
\r
98 > (setq start next-pos)))
\r
101 > +;; process-attributes is not defined everywhere, so define an
\r
102 > +;; alternate way to test if a process still exists.
\r
104 > +(defun test-process-running (pid)
\r
106 > + (signal-process pid 0)))
\r
108 > (defun orphan-watchdog-check (pid)
\r
109 > "Periodically check that the process with id PID is still
\r
110 > running, quit if it terminated."
\r
111 > - (if (not (process-attributes pid))
\r
112 > + (if (not (test-process-running pid))
\r
115 > (defun orphan-watchdog (pid)
\r
116 > "Initiate orphan watchdog check."
\r
117 > - ; If process-attributes returns nil right away, that probably means
\r
118 > - ; it is unimplimented. So we delay two minutes before killing emacs.
\r
120 Btw: who let this typo above pass through review ? ;)
\r
122 > - (if (process-attributes pid)
\r
123 > - (run-at-time 60 60 'orphan-watchdog-check pid)
\r
124 > - (run-at-time 120 60 'orphan-watchdog-check pid)))
\r
125 > + (run-at-time 60 60 'orphan-watchdog-check pid))
\r
127 > (defun hook-counter (hook)
\r
128 > "Count how many times a hook is called. Increments
\r