From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18038 invoked by alias); 19 Feb 2017 08:04:43 -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: 40580 Received: (qmail 11290 invoked from network); 19 Feb 2017 08:04:43 -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 0.763913 secs); 19 Feb 2017 08:04:43 -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:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=mesmtp; bh=RZxiuwOtJ62zDllmEHiKvoLux5 w=; b=hzRsBOhmDNzSlcFQZUQYBOGtn0Zt3AjxmSr+R5Cj7DtGf/zDMrJxEFwizu EKMx369pfNil2OjsMIbKhE85ECfae2ZQ4SqzfzgfzTYDYFu/ImO9iQqezsHhSIs1 4mrMRImHys6z9Mdr4I5Cx8kv5qVKMOclXszyn+GKw5cFzWGRo= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=smtpout; bh=RZ xiuwOtJ62zDllmEHiKvoLux5w=; b=rZtlDmuT2teTI0yOuOugZtsZDOU04bIv0g hoQUMCgQwY/nyJboaoKko5B6SLqiS+yrKVt5/OwbxzZ+On1Nijo+aj4Ncq8lzkIH NADxifUzkBPbJkKnu9PSCasRmPp4x5Q+S/3JhboTenxAEr/m3nmJ8PuQt3DB/qwo wglTWmaEQ= X-ME-Sender: Message-Id: <1487491478.281773.885668344.1F5A7E47@webmail.messagingengine.com> From: Sebastian Gniazdowski To: Bart Schaefer , 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 References: <1487421943.63900.885130720.703DA037@webmail.messagingengine.com> <170218210200.ZM27007@torch.brasslantern.com> In-Reply-To: <170218210200.ZM27007@torch.brasslantern.com> Subject: Re: Closing descriptors in forked (pipe) command Date: Sun, 19 Feb 2017 00:04:38 -0800 On Sat, Feb 18, 2017, at 09:02 PM, Bart Schaefer wrote: > On Feb 18, 4:45am, Sebastian Gniazdowski wrote: > } > } in db/gdbm module, I do: > } addmodulefd(gdbm_fdesc(dbf), FDT_MODULE); > }=20 > } The point is: forked process inherits database connection. GDBM cannot > } have multiple writers (open is in write mode). >=20 > That's not true -- "man gdbm" even mentions: >=20 > If the database was opened with the GDBM_NOLOCK flag, the user may > wish to perform their own file locking on the database file in order > to prevent multiple writers operating on the same file simultaneously. This would make GDBM quite standout, except I probably superficially interpreted what I was reading. My opinion about GDBM comes from the fact that I cannot have reader + writer with gdbmtool, i.e. run once "gdbmtool -r db", then "gdbmtool db" =E2=80=93=C2=A0first program will stop= working: stdin:1.5: cannot open db: Can't be reader The superficial reading was one other DBM database that was stating boldly about no simultaneous access, but I think it was also stating that multiple threads are possible. Sorry cannot find that again. But this would reveal that it can be about proper locking, not simultaneous access itself. Either way GDBM has nice potential but I might not be able to leverage it in the module. Fast ztie, hash scan, untie is quite much as custom locking & unlocking to access database. > } Maybe it would be good to solve this? FDT_FORKCLOSE or something, there > } is closeallelse(), for multiio, didn't go deeper in this. >=20 > In the general case a subshell should be inheriting all descriptors from > the parent, and it's up to the shell programmer not to do stupid things. > Consider the case where the parent shell wishes to ztie to the database, > fork off a subshell that will make use of the tied parameter, and then > go on to exec something else or otherwise exit, leaving the subshell to > manage the database. Ok, with file position pointer sanity, and "file has changed" sanity of GDBM, this is in quite good state and the use case you wrote is available to the user. --=20 Sebastian Gniazdowski