From: "Morten Kjærulff" <mortenkjarulff@gmail.com>
To: cygwin@cygwin.com
Subject: name pipe problem: 1 writer, multiple concurrent readers
Date: Tue, 19 May 2020 13:26:44 +0200 [thread overview]
Message-ID: <CA+7cx1p-vH6D9MsQ=zhx2nNDU+8S_oCXmpvNeMp0rwMr2L3RFw@mail.gmail.com> (raw)
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
next reply other threads:[~2020-05-19 11:26 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-19 11:26 Morten Kjærulff [this message]
2020-05-19 13:14 ` Ken Brown
[not found] ` <CA+7cx1pjvJOzMM3bwspdWGHowC+dSkPx+SrOH6wtyRO367hCJQ@mail.gmail.com>
2020-05-20 22:03 ` Ken Brown
2020-07-02 17:50 ` Morten Kjærulff
2020-07-03 11:09 ` Ken Brown
2020-07-16 19:26 ` Ken Brown
2020-08-07 8:06 ` Morten Kjærulff
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='CA+7cx1p-vH6D9MsQ=zhx2nNDU+8S_oCXmpvNeMp0rwMr2L3RFw@mail.gmail.com' \
--to=mortenkjarulff@gmail.com \
--cc=cygwin@cygwin.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).