www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2025/05/21/06:14:59

DMARC-Filter: OpenDMARC Filter v1.4.2 delorie.com 54LAEx403464472
Authentication-Results: delorie.com; dmarc=pass (p=none dis=none) header.from=cygwin.com
Authentication-Results: delorie.com; spf=pass smtp.mailfrom=cygwin.com
DKIM-Filter: OpenDKIM Filter v2.11.0 delorie.com 54LAEx403464472
Authentication-Results: delorie.com;
dkim=pass (1024-bit key, unprotected) header.d=cygwin.com header.i=@cygwin.com header.a=rsa-sha256 header.s=default header.b=tyriYJD9
X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 862F53857C6C
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1747822496;
bh=iLULS6KArEQuZljBspU+EZfU8QU8/0K6Tf7DI3mF/kk=;
h=Subject:To:Date:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:Cc:From;
b=tyriYJD9yFJbuXIMhL9x9QtvxrtjgB82KfILAjLwCGHrMZEqw547WlDeo0SWnNzLe
R39fNcvJcL+BnMQcEHsyW+DOEubxj7X9UE09qTVn73IaHbeMnggzPufCJtLepvrQy9
TV5CqkBnNCVLmRq5KBi9eMmIvE1IkHLFxg0kAYFw=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8EFCD385840F
ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 8EFCD385840F
ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1747822472; cv=none;
b=pTVyOCIUo/RwFS8e72jyMKK1wUxAH7F0iJN8xHmIH2VR4h6KaRC0xCEEEQKjdFqNLC6rYediCbREDj4ihjHHb1leFVS/MK3gc2IZ/hkfBOKK2F3GtmZ6k5Jowp3xp1JqUUeuVr3HMwoLvHXGWq8/6HMSJ+u0E2V0AO4VouwCrKg=
ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key;
t=1747822472; c=relaxed/simple;
bh=DIjqGLJmYWNlTaQCm3LKE/3xLJXT+wBwAOVDV5MvBAM=;
h=From:Subject:To:Message-ID:Date:MIME-Version;
b=BtXclz05ABlHqx+B+KXisQmgE19yyIfw8WTLwu5PWLq65togplXVBirJICP2yQfqrw3rGVaennE4ev3Fo/FIbXEVQyP8YOOiXMG9eTEo6mK7kHEbkPx/yn4xtvMhzTKlt0YuFSGCt8lJyYdhPNXKQ6W4Q/46G2qstwSz0Oiw5bU=
ARC-Authentication-Results: i=1; server2.sourceware.org
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8EFCD385840F
Subject: EBADF from write() if foreign pty is opened via /proc/PID/fd/N symlink
To: cygwin AT cygwin DOT com
Message-ID: <82b490da-145a-1428-e253-6f47983794db@t-online.de>
Date: Wed, 21 May 2025 12:14:31 +0200
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101
SeaMonkey/2.53.20
MIME-Version: 1.0
X-TOI-EXPURGATEID: 150726::1747822470-6BFFD569-54092068/0/0 CLEAN NORMAL
X-TOI-MSGID: 75bf7315-d78b-4088-8d66-b8693d5e5201
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.30
List-Id: General Cygwin discussions and problem reports <cygwin.cygwin.com>
List-Archive: <https://cygwin.com/pipermail/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-request AT cygwin DOT com?subject=help>
List-Subscribe: <https://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: Christian Franke via Cygwin <cygwin AT cygwin DOT com>
Reply-To: cygwin AT cygwin DOT com
Cc: Christian Franke <Christian DOT Franke AT t-online DOT de>
Sender: "Cygwin" <cygwin-bounces~archive-cygwin=delorie DOT com AT cygwin DOT com>

Unexpected behavior of an uncommon use case:

$ uname -r
3.7.0-0.98.gb39b510c1ce6.x86_64

$ cygstart mintty - # Start second terminal

In second terminal:

$ echo $$; tty
1219
/dev/pty1

Back to first terminal:

$ dd of=/proc/1219/fd/1 <<<"Hello" # errno=EBADF
dd: error writing '/proc/1219/fd/1': Bad file descriptor
0+1 records in
0+0 records out
0 bytes copied, 8.22e-05 s, 0.0 kB/s

$ readlink /proc/1219/fd/1
/dev/pty1

$ dd of=/dev/pty1 <<<"Hello" # OK, text appears in 2nd terminal
0+1 records in
0+1 records out
6 bytes copied, 5.41e-05 s, 111 kB/s

$ dd of=/proc/$$/fd/1 <<<"Hello" # OK
Hello
0+1 records in
0+1 records out
6 bytes copied, 4.77e-05 s, 126 kB/s

The problem apparently only occurs if /proc/PID/fd/N points to a foreign 
pty. It works for own pty or regular files.

-- 
Regards,
Christian


-- 
Problem reports:      https://cygwin.com/problems.html
FAQ:                  https://cygwin.com/faq/
Documentation:        https://cygwin.com/docs.html
Unsubscribe info:     https://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019