Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: When is mem.c / malloc called?
- X-seq: zsh-workers 40520
- From: Sebastian Gniazdowski <psprint2@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: When is mem.c / malloc called?
- Date: Fri, 10 Feb 2017 11:45:38 -0800
- 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=
- In-reply-to: <170210102523.ZM28915@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1486729474.1489636.876722008.7B4EC1FC@webmail.messagingengine.com> <170210102523.ZM28915@torch.brasslantern.com>
On Fri, Feb 10, 2017, at 10:25 AM, Bart Schaefer wrote:
> } I'm writing a module that needs thread safe memory allocation.
>
> 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.
>
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=( a b c d )
I basically create a thread after I do:
fdopen( dup( fileno( stdin ) ), "r" );
in module's builtin – zpopulator. 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).
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/41f40f7b35c67fed907d660b620f4ec5bda6022e/module/Src/psprint/zpopulator.c#L438-L442
--
Sebastian Gniazdowski
Messages sorted by:
Reverse Date,
Date,
Thread,
Author