Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / d9 / edcb360d83236f814ac2a80421394cc6a14cec
1 Return-Path: <dmitry.kurochkin@gmail.com>\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 096BF431FD0\r
6         for <notmuch@notmuchmail.org>; Mon, 19 Dec 2011 13:29:40 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id Q6W73kDkKDGm for <notmuch@notmuchmail.org>;\r
17         Mon, 19 Dec 2011 13:29:39 -0800 (PST)\r
18 Received: from mail-wi0-f181.google.com (mail-wi0-f181.google.com\r
19         [209.85.212.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id E7A5E431FB6\r
22         for <notmuch@notmuchmail.org>; Mon, 19 Dec 2011 13:29:38 -0800 (PST)\r
23 Received: by wibhq2 with SMTP id hq2so1591735wib.26\r
24         for <notmuch@notmuchmail.org>; Mon, 19 Dec 2011 13:29:36 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
26         h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
27         :mime-version:content-type;\r
28         bh=PMKfCg/t4qCUDaXXBbaXEFcHYdGCWJ2QJiwHcM6YmaU=;\r
29         b=HJFsRBPf7nDVTNfqnMeyYKa4BXRmbxETV9zBzXPy1A3SdoiqxHEXsaqehN/iYks7nk\r
30         ltDbICtzsAFwzMZjD+Hd3Zulkkvcw6rtoJdjBBTf7bwmg92P2R9fCqoy8UdWL7X/32za\r
31         I/ZnwfPqDvBQWSP54GtOhoXMaIjfM4d7YYFP4=\r
32 Received: by 10.180.91.201 with SMTP id cg9mr2277512wib.15.1324330176412;\r
33         Mon, 19 Dec 2011 13:29:36 -0800 (PST)\r
34 Received: from localhost ([91.144.186.21])\r
35         by mx.google.com with ESMTPS id dy1sm27492245wib.18.2011.12.19.13.29.34\r
36         (version=TLSv1/SSLv3 cipher=OTHER);\r
37         Mon, 19 Dec 2011 13:29:35 -0800 (PST)\r
38 From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
39 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
40 Subject: Re: [PATCH 1/2] test/smtp-dummy: add --background option for going\r
41         background after listen(2)\r
42 In-Reply-To: <1323766883-17607-1-git-send-email-tomi.ollila@iki.fi>\r
43 References: <20111212161800.GO2760@mit.edu>\r
44         <1323766883-17607-1-git-send-email-tomi.ollila@iki.fi>\r
45 User-Agent: Notmuch/0.10.2+96~g74e5ae5 (http://notmuchmail.org) Emacs/23.3.1\r
46         (x86_64-pc-linux-gnu)\r
47 Date: Tue, 20 Dec 2011 01:28:53 +0400\r
48 Message-ID: <874nwwxnca.fsf@gmail.com>\r
49 MIME-Version: 1.0\r
50 Content-Type: text/plain; charset=us-ascii\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Mon, 19 Dec 2011 21:29:40 -0000\r
64 \r
65 Hi Tomi.\r
66 \r
67 On Tue, 13 Dec 2011 11:01:22 +0200, Tomi Ollila <tomi.ollila@iki.fi> wrote:\r
68 > To avoid the possibility that smtp-dummy doesn't have chance to bind\r
69 > its listening socket until something tries to send message to it this\r
70 > option makes caller wait until socket is already listening for connections.\r
71\r
72 > In case this --background option is used, the pid of running smtp-dummy\r
73 > is printed on stdout.\r
74 > ---\r
75\r
76 > Resent after whitespace-cleanup in patch 1/2 (this patch).\r
77\r
78 >  test/smtp-dummy.c |   35 ++++++++++++++++++++++++++++++++++-\r
79 >  1 files changed, 34 insertions(+), 1 deletions(-)\r
80\r
81 > diff --git a/test/smtp-dummy.c b/test/smtp-dummy.c\r
82 > index 3801a5e..9126c00 100644\r
83 > --- a/test/smtp-dummy.c\r
84 > +++ b/test/smtp-dummy.c\r
85 > @@ -124,9 +124,21 @@ main (int argc, char *argv[])\r
86 >       struct hostent *hostinfo;\r
87 >       socklen_t peer_addr_len;\r
88 >       int reuse;\r
89 > +     int bg;\r
90 \r
91 I would rename bg to background, but that is not important.\r
92 \r
93 > +\r
94 > +     /* XXX Quick implementation -- fix if more functionality is desired. */\r
95 > +     if (argc >= 2 && strcmp(argv[1], "--background") == 0) {\r
96 > +             argc--;\r
97 > +             argv[1] = argv[0];\r
98 > +             argv++;\r
99 > +             bg = 1;\r
100 > +     }\r
101 > +     else\r
102 > +             bg = 0;\r
103 >  \r
104 \r
105 Sorry, this code looks ugly and unnecessary complex to me.  I really do\r
106 not like messing with argc and argv.  Perhaps something like this would\r
107 be better:\r
108 \r
109   if (argc != 2 && argc != 3)\r
110     usage();\r
111     return 1;\r
112 \r
113   if (argc > 2) {\r
114     if (argv[1] == background)\r
115       bg = 1;\r
116     else\r
117       usage();\r
118       return 1;\r
119   }\r
120 \r
121   output = argv[argc - 1];\r
122 \r
123 >       if (argc != 2) {\r
124 > -             fprintf (stderr, "Usage: %s <output-file>\n", argv[0]);\r
125 > +             fprintf (stderr, "Usage: %s [--background] <output-file>\n",\r
126 > +                      argv[0]);\r
127 >               return 1;\r
128 >       }\r
129 >  \r
130 > @@ -179,7 +191,27 @@ main (int argc, char *argv[])\r
131 >               return 1;\r
132 >       }\r
133 >  \r
134 > +     if (bg) {\r
135 > +             int pid = fork ();\r
136 > +             if (pid > 0) {\r
137 > +                     printf ("%d\n", pid);\r
138 > +                     return 0;\r
139 > +             }\r
140 > +             if (pid < 0) {\r
141 > +                     fprintf (stderr, "Error: fork() failed: %s\n",\r
142 > +                              strerror (errno));\r
143 > +                     close (sock);\r
144 > +                     return 1;\r
145 > +             }\r
146 > +             /* Reached if pid == 0. */\r
147 > +             /* Close stdout so that the one interested in pid value will\r
148 > +                also get EOF. */\r
149 > +             close (1);\r
150 \r
151 Please use STDOUT_FILENO instead of 1.\r
152 \r
153 > +             /* dup2() will re-reserve fd 1 (opportunistically, in case fd 2\r
154 > +                is open. If that was not open we don't care fd 1 either.) */\r
155 > +             dup2 (2, 1);\r
156 \r
157 And STDERR_FILENO and STDOUT_FILENO here.  I would prefer to see "stdout"\r
158 and "stderr" instead of "1" and "2" in the comments as well.\r
159 \r
160 Regards,\r
161   Dmitry\r
162 \r
163 > +     }\r
164 > +\r
165 >       peer_addr_len = sizeof (peer_addr);\r
166 >       peer = accept (sock, (struct sockaddr *) &peer_addr, &peer_addr_len);\r
167 >       if (peer == -1) {\r
168 > -- \r
169 > 1.7.7.3\r
170\r
171 > _______________________________________________\r
172 > notmuch mailing list\r
173 > notmuch@notmuchmail.org\r
174 > http://notmuchmail.org/mailman/listinfo/notmuch\r