From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 204 invoked by alias); 10 Feb 2017 19:45:46 -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: 40520 Received: (qmail 20378 invoked from network); 10 Feb 2017 19:45:46 -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 1.348431 secs); 10 Feb 2017 19:45:46 -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=TTzTcyajkCB3Q+BiCmydrEj60/ o=; b=eemngvzdComJK8F2oK/Mv5ciTAVnPwakMoW+MpiIDZvv/yG+fIBPmE3Keh xuzrnB4qIZ9YC1+MgTAbswPhOetTD1wh7G5kpM68/0YF+u8uU/Qwtjd8+9c1IKoR Nfti4BJ26iFMhWkinzOU46DJYhP5HEk73QL9e9m8yf2gSqfXI= 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=TT zTcyajkCB3Q+BiCmydrEj60/o=; b=msyS8NWI6RgtP4aGgut+CecrSYUq4UJFbX srSe4WMRLXqw5s3ltXesN38KfqSiImWLfRt/Au+ylJZHPRZwxADCXY6bI0mr5wNk JSUjFk5rczNqXEp4z0jGWKGsba0S5mc/vfMGGy2oeToh322Vw6s6cLMwnVcj/0/j Fi6cnG/yk= X-ME-Sender: Message-Id: <1486755938.1593082.877179952.42D3C472@webmail.messagingengine.com> From: Sebastian Gniazdowski To: zsh-workers@zsh.org, Bart Schaefer MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Mailer: MessagingEngine.com Webmail Interface - ajax-4a450d19 References: <1486729474.1489636.876722008.7B4EC1FC@webmail.messagingengine.com> <170210102523.ZM28915@torch.brasslantern.com> In-Reply-To: <170210102523.ZM28915@torch.brasslantern.com> Subject: Re: When is mem.c / malloc called? Date: Fri, 10 Feb 2017 11:45:38 -0800 On Fri, Feb 10, 2017, at 10:25 AM, Bart Schaefer wrote: > } I'm writing a module that needs thread safe memory allocation. >=20 > This sounds pretty dangerous, as the rest of zsh (signal handling in > particular, update of the environment on e.g. "export", etc.) is not > going to be thread-safe. >=20 I've ended up copying multiple Zsh functions, calling them my_{original_name}, creating separate call tree. The goal is to do this in multi-threaded manner: # print -rl -- "a,b" "c,d" | zpopulator -D , -vA myhash # typeset -p myhash typeset -A myhash=3D( a b c d ) I basically create a thread after I do: fdopen( dup( fileno( stdin ) ), "r" ); in module's builtin =E2=80=93=C2=A0zpopulator. I was counting on: Zsh will = think module command ended because main thread will do "return 0", it will not break the pipe because it gets broken by itself when reader or writer exits. This way the forked "print -rl" and the thread-splitted "zpopulator" could work in background. However I just discovered that: # ls -R / | zpopulator -D , -vA myhash DOES block shell.. I successfully obtained no-block behavior but it was zpopulator that was persisting, not the writing process (forked one).=20 Have you any idea how to cause above to not block shell? zpopulator's thread exits from module's builtin, this should be close to unblock shell.. Code: https://github.com/psprint/zpopulator/blob/41f40f7b35c67fed907d660b620f4ec5= bda6022e/module/Src/psprint/zpopulator.c#L438-L442 --=20 Sebastian Gniazdowski