From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29491 invoked by alias); 18 Feb 2017 12:45:55 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 40572 Received: (qmail 2191 invoked from network); 18 Feb 2017 12:45:55 -0000 X-Qmail-Scanner-Diagnostics: from new1-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(66.111.4.221):SA:0(-0.4/5.0):. Processed in 2.035311 secs); 18 Feb 2017 12:45:55 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-0.4 required=5.0 tests=FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: psprint2@fastmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at spf.messagingengine.com designates 66.111.4.221 as permitted sender) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= mesmtp; bh=oivVu28tur9HNvlzCSWPyQyLqLA=; b=xqRO9wOoMfgg63EYY6Lcv +cW/ajog2YX0bsZo3xZJhkhmCChJNahd++XeV9BaOlRxFoBqwaiIH9LmA0pBziAO wJI2p8RPlQLQ2TKCJngrtNq0X1rDilwEVyBugsNR7fpNq175QvxYiAOvdNQzrYec sw6rT2FsXJXmiD02EPltkA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:message-id:mime-version:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=smtpout; bh=oivVu28tur9HNvlzCSWPyQyLq LA=; b=VsHTIUHRZ3iBD4KGW4vM6inC6FyzJa/UHII4XMPnbFQg6TwvrAIQ0bs5K gfGrk7PvoWrvf6zzfyIRwCckvdD6HJpBICVA0C5RswJMzBf1+ZZl9MNPeZY6PclA IkcWRScdzfMIY1NTQhLlL/bgWl4Wi06qmSngkYuK0EDAlofPdg= X-ME-Sender: Message-Id: <1487421943.63900.885130720.703DA037@webmail.messagingengine.com> From: Sebastian Gniazdowski To: zsh-workers@zsh.org MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-715c2c0c Date: Sat, 18 Feb 2017 04:45:43 -0800 Subject: Closing descriptors in forked (pipe) command Hello, in db/gdbm module, I do: addmodulefd(gdbm_fdesc(dbf), FDT_MODULE); this should lead to problem, but it behaves the same as with FDT_INTERNAL, i.e. following: % ztie -d db/gdbm -f ~/db3 mybase2 % fun() { while read line; do echo $line; done } % eval "print -rl -- \${(kv)mybase2[@]}" | fun % echo $mybase2 The point is: forked process inherits database connection. GDBM cannot have multiple writers (open is in write mode). Above outputs: (Dbase accessed) testkey testdata (Dbase accessed) testkey testdata "(Dbase accessed)" is printf from code where $mybase2 turns out to be empty for given key and database fetch is ordered. So it's visible that there is fork because database is accessed twice =E2=80=93 $mybase2 is still empty at line "echo $mybase2". Good that GDBM handles change to file-descriptor's file position pointer (AFAIK it's shared between FDs), and reads the data again correctly. With write it also works, but potentially the database might get corrupted silently: % ztie -d db/gdbm -f ~/db3 mybase2 % fun() { while read line; do echo $line; done } % eval "mybase2[=E6=BC=A2]=3D=E5=AD=97" | fun (Dbase accessed) % echo $mybase2[=E6=BC=A2] (Dbase accessed) =E5=AD=97 Maybe it would be good to solve this? FDT_FORKCLOSE or something, there is closeallelse(), for multiio, didn't go deeper in this. --=20 Sebastian Gniazdowski psprint2@fastmail.com