zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <Stephane_Chazelas@yahoo.fr>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: PATCH: allocating a new file descriptor
Date: Thu, 14 Apr 2005 19:10:20 +0100	[thread overview]
Message-ID: <20050414181020.GA5064@sc> (raw)
In-Reply-To: <200504141616.j3EGGR7O023489@news01.csr.com>

I understand that

exec {fd}> file

is the shell equivalent of

fd = open(file, O_WRONLY|O_CREAT);

given that we already have ztcp, zsocket... that allocate fds,
and sysread, syswrite..., I would find it more consistent to
have:

sysopen -w file
fd=$REPLY

(with -x (O_EXCL), -r (read), -w (write), -a (append), -n (don't
create), -d <fd> and possibly extensions for O_SYNC, O_NOATIME...)

I find the:

print ... {fd}> file

that keeps the file open a bit confusing and unconsistent (and
useless).

It would be good to have a sysclose as well. At least until
recently, exec 12>&- didn't work. I had the problem with my
mouse support, where I couldn't close the fd opened by zsocket
for gpm interaction.

I also noticed several problems when fidling with fds used
internally by zsh (zsocket -d10 or -d11 ended up in a core
dump).

sysdup2 may come handy as well if exec 12>&13, or exec $a>&$b
don't work.

regards,
Stéphane


  reply	other threads:[~2005-04-14 18:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-12 12:57 Peter Stephenson
2005-04-12 17:35 ` Peter Stephenson
2005-04-14  4:57 ` Bart Schaefer
2005-04-14  9:49   ` Peter Stephenson
2005-04-14 14:23     ` Bart Schaefer
2005-04-14 16:16       ` Peter Stephenson
2005-04-14 18:10         ` Stephane Chazelas [this message]
2005-04-15 10:27           ` Peter Stephenson
2005-04-15 16:19             ` Bart Schaefer
2005-04-15 19:06               ` Peter Stephenson

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=20050414181020.GA5064@sc \
    --to=stephane_chazelas@yahoo.fr \
    --cc=zsh-workers@sunsite.dk \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).