delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2020/05/19/07:27:58

X-Recipient: archive-cygwin AT delorie DOT com
DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6263A3897813
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cygwin.com;
s=default; t=1589887634;
bh=5rZWJOE5gzOcgbHQZz67nQgnvyffV5YlyvQ8UBEXSVU=;
h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post:
List-Help:List-Subscribe:From:Reply-To:From;
b=k2z08UrE6NIWf6unojTQ1hV8FIIx/zGEvjrt+saWC+Ar0RciRUYHd/sDk17gEGRMV
qMGBVh8dlCxZ+1O0yCjmBoX687TYS6g0upyK1ho+VBO5/arjhUsv6o/PuJFiHVjGm1
3jm6PVb2QXzki2gj/govAlAbdffn+VkQXX9PFV9M=
X-Original-To: cygwin AT cygwin DOT com
Delivered-To: cygwin AT cygwin DOT com
DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D07C1384A87E
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20161025;
h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
bh=Dupn0tkUpicxYcW4CYG19wcafowUr0WUQmTo3876hyA=;
b=VQLDRTQv49QLQGsH73PBtgThKrf4mileJ2XCS/T+Z+ta5r8sza0jTVfrlj6jznI+6p
Y+x0LPyKJjb+5tAFqJmT7zShQHNFKCrIKvcLncT8tY6q+WQdAMXeoPQZJSkwocsIMwVz
wrc1/QKVdmAWT7FKp9/aq1F9J695M3Ivs4JACNGY7cqxub6IyEPX1cpRULR5DVEsP9fP
WLg5PuLDCwXW9frKix5l6c9OmQ8q9gKZ0EraUT6DsXhSYmo/Arwg72oai12Jdiqey8U7
Lx/jGo9c1ZvDGoz8X5OfduPSPfRmGzrUl1SRVK2LTDeEWctasAgWuUEUjO3AlL6HLkzH
HzQw==
X-Gm-Message-State: AOAM533c+v4HqGxF/26K8b1VNWhVybQVmbnTn2PNyrhAQzJUr7hCiPB3
j3j5c2z/O8TYSKPPYhsPsHyQF2sAR5L6ZmwnfF3AhOwi
X-Google-Smtp-Source: ABdhPJzWhkjaMt9S7e7zPBBAl7DbwmLXekScfrQXbF4CpI2WIlT+VVP0O7Xrv3eVbw9VuSuAMJGFTvA/BTzyjvl9P58=
X-Received: by 2002:a17:907:40c7:: with SMTP id
nv7mr17886510ejb.16.1589887615547;
Tue, 19 May 2020 04:26:55 -0700 (PDT)
MIME-Version: 1.0
Date: Tue, 19 May 2020 13:26:44 +0200
Message-ID: <CA+7cx1p-vH6D9MsQ=zhx2nNDU+8S_oCXmpvNeMp0rwMr2L3RFw@mail.gmail.com>
Subject: name pipe problem: 1 writer, multiple concurrent readers
To: cygwin AT cygwin DOT com
X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00, DKIM_SIGNED,
DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, KAM_LINEPADDING,
RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS,
TXREP autolearn=no autolearn_force=no version=3.4.2
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on
server2.sourceware.org
X-BeenThere: cygwin AT cygwin DOT com
X-Mailman-Version: 2.1.29
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: <http://cygwin.com/mailman/listinfo/cygwin>,
<mailto:cygwin-request AT cygwin DOT com?subject=subscribe>
From: =?utf-8?q?Morten_Kj=C3=A6rulff_via_Cygwin?= <cygwin AT cygwin DOT com>
Reply-To: =?UTF-8?Q?Morten_Kj=C3=A6rulff?= <mortenkjarulff AT gmail DOT com>
Sender: "Cygwin" <cygwin-bounces AT cygwin DOT com>

Hi,

The following script:

#!/bin/sh

rm -f t.pip t.txt

mkfifo t.pip
printf "line1\nline2\n" >t.txt

ps

{
  while true ; do
    cp t.txt t.pip
  done
} &

rm -f t.rc.*
for rc in 0 1 2 3 4 5 6 7 8 9 ; do
  {
    diff t.pip t.txt
    echo $? >t.rc.$rc
  }
done
echo result1 start
ls  t.rc.* | wc -l
cat t.rc.*
echo result1 end

rm -f t.rc.*
for rc in 0 1 2 3 4 5 6 7 8 9 ; do
  {
    diff t.pip t.txt
    echo $? >t.rc.$rc
  } & # run the readers in parallel
done
sleep 10
echo result2 start
ls  t.rc.* | wc -l
cat t.rc.*
echo result2 end

ps

Give me output like this:

$ ./tpip.sh
      PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
     1642    1600    1642      65264  cons1    1058872 13:18:58 /usr/bin/sh
     1600       1    1600      72728  cons1    1058872 13:18:33 /usr/bin/bash
     1645    1642    1642      42088  cons1    1058872 13:18:58 /usr/bin/ps
result1 start
10
0
0
0
0
0
0
0
0
0
0
result1 end
0a1,2
> line1
> line2
diff: t.pip
result2 start
1
2
result2 end
      PID    PPID    PGID     WINPID   TTY         UID    STIME COMMAND
     1690    1688    1642     104032  cons1    1058872 13:19:01 /usr/bin/diff
     1681    1642    1642      95012  cons1    1058872 13:19:00 /usr/bin/sh
     1642    1600    1642      65264  cons1    1058872 13:18:58 /usr/bin/sh
     1684    1681    1642      99624  cons1    1058872 13:19:00 /usr/bin/diff
     1678    1676    1642      94532  cons1    1058872 13:19:00 /usr/bin/diff
     1688    1642    1642      88864  cons1    1058872 13:19:01 /usr/bin/sh
     1698    1642    1642     104820  cons1    1058872 13:19:11 /usr/bin/ps
     1692    1642    1642      66572  cons1    1058872 13:19:01 /usr/bin/sh
     1677    1674    1642      86692  cons1    1058872 13:19:00 /usr/bin/diff
     1646    1642    1642      30888  cons1    1058872 13:18:58 /usr/bin/sh
     1600       1    1600      72728  cons1    1058872 13:18:33 /usr/bin/bash
     1686    1685    1642      14320  cons1    1058872 13:19:01 /usr/bin/diff
     1685    1642    1642      25608  cons1    1058872 13:19:00 /usr/bin/sh
     1676    1642    1642     104212  cons1    1058872 13:19:00 /usr/bin/sh
     1689    1642    1642      98004  cons1    1058872 13:19:01 /usr/bin/sh
     1674    1642    1642      44152  cons1    1058872 13:19:00 /usr/bin/sh
     1680    1646    1642      28224  cons1    1058872 13:19:00 /usr/bin/cp
     1682    1679    1642      43612  cons1    1058872 13:19:00 /usr/bin/diff
     1694    1692    1642      67736  cons1    1058872 13:19:01 /usr/bin/diff
     1683    1642    1642      93544  cons1    1058872 13:19:00 /usr/bin/sh
     1679    1642    1642      90188  cons1    1058872 13:19:00 /usr/bin/sh
     1691    1689    1642      68560  cons1    1058872 13:19:01 /usr/bin/diff
     1687    1683    1642      83952  cons1    1058872 13:19:01 /usr/bin/diff

$

That is, when I run the readers in sequence, no problem, but when I
run the in parallel, they either hang or t.pip seems empty.

Is this as expected?

My final goal is to have my .netrc file encrypted. t.pip would be
.netrc and t.txt would be the encrypted one. If I can get to my goal
another way, feel free to give me the idea.

/Morten
--
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