linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: janusz.uzycki@elproma.com.pl
Cc: linux-can@vger.kernel.org,
	Krzysztof Borgulski <k.borgulski@elproma.com.pl>
Subject: Re: [PATCH] slcanpty
Date: Sat, 08 Jun 2013 13:09:16 +0200	[thread overview]
Message-ID: <51B310DC.8040509@hartkopp.net> (raw)
In-Reply-To: <6f9fdd56db06e6029218834c526f7d15@beep.pl>

Hi Janusz,

thanks for the patch.

I changed it in the way the perror() is only called on negative return values.

Please check it out for a test.

Best regards,
Oliver

On 07.06.2013 15:40, janusz.uzycki@elproma.com.pl wrote:
> Hi Oliver.
> 
> I've tested the following case:
> modprobe vcan
> ip link add dev vcan0 type vcan
> #ip link set vcan0 up type can bitrate 125000
> ip link set vcan0 up
> socat PTY,link=/tmp/a -
> cgdb --args ./slcanpty /tmp/a vcan0
> 
> If socat killed slcanpty should finish instead of crazy loop (select always
> returns).
> Here is proposal of very little patch:
> From a708491ea49e170ac1d36148e75b7b6c6f07b6fd Mon Sep 17 00:00:00 2001
> From: Janusz Uzycki <j.uzycki@elproma.com.pl>
> Date: Fri, 7 Jun 2013 15:25:39 +0200
> Subject: slcanpty: detect that master PTY descriptor closed
> 
> 
> Signed-off-by: Janusz Uzycki <j.uzycki@elproma.com.pl>
> ---
>  slcanpty.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/slcanpty.c b/slcanpty.c
> index f3628b9..061c1ab 100644
> --- a/slcanpty.c
> +++ b/slcanpty.c
> @@ -75,7 +75,7 @@ int pty2can(int pty, int socket, struct can_filter *fi,
>         int tmp, i;
> 
>         nbytes = read(pty, &buf, sizeof(buf)-1);
> -       if (nbytes < 0) {
> +       if (nbytes <= 0) { /* 0 means that master PTY descriptor has been
> closed */
>                 perror("read pty");
>                 return 1;
>         }
> -- 
> 1.7.11.3
> 
> best regards
> Janusz
> 


  reply	other threads:[~2013-06-08 11:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <2DAB3DC2841347E7AF7833620339B427@laptop2>
2013-06-05 19:44 ` slcanpty Oliver Hartkopp
2013-06-06 12:03   ` slcanpty Janusz Uzycki
2013-06-06 18:31     ` slcanpty Oliver Hartkopp
2013-06-06 20:43       ` slcanpty janusz.uzycki
2013-06-07 13:40       ` [PATCH] slcanpty janusz.uzycki
2013-06-08 11:09         ` Oliver Hartkopp [this message]
2013-06-10  9:06           ` janusz.uzycki
2013-06-10  9:16             ` janusz.uzycki
2013-06-10  9:36               ` janusz.uzycki
2013-06-10  9:42                 ` [PATCH 1/2] slcanpty: "slcanpty < /dev/null" issue fix janusz.uzycki
2013-06-10  9:44                   ` [PATCH 2/2] slcanpty: /dev/tty support for tests janusz.uzycki
2013-06-10  9:53                     ` janusz.uzycki
2013-06-10 18:29                       ` Oliver Hartkopp
2013-06-10 18:38                         ` janusz.uzycki
2013-06-11 20:28                           ` Oliver Hartkopp
2013-06-11 16:29       ` slcanpty janusz.uzycki
2013-06-11 20:32         ` slcanpty Oliver Hartkopp
2013-06-11 21:19           ` slcanpty janusz.uzycki
2013-06-12 15:25             ` slcanpty Oliver Hartkopp
2013-06-14  8:42               ` slcanpty Janusz Uzycki
2013-06-18  8:24               ` slcanpty j.uzycki
2013-06-19 17:15                 ` slcanpty Oliver Hartkopp
2013-06-19 22:39                   ` slcanpty j.uzycki

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51B310DC.8040509@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=janusz.uzycki@elproma.com.pl \
    --cc=k.borgulski@elproma.com.pl \
    --cc=linux-can@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).