linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "A. Murat Eren" <meren@comu.edu.tr>
To: linux-c-programming@vger.kernel.org
Subject: Re: [Fwd: Re: Implementing a file counter (like "ls | wc")]
Date: Thu, 8 Apr 2004 11:05:13 +0300	[thread overview]
Message-ID: <200404081105.13485.meren@comu.edu.tr> (raw)
In-Reply-To: <16500.55163.50294.74986@cerise.nosuchdomain.co.uk>


 Hi,

> "cd" isn't a program; it's a built-in shell command. It has to be; a
> process can't change the current directory of another process, so a
> "cd" program just wouldn't work.

 Sorry about that, yes cd is a built-in function of shell. btw, i'm not using 
it to change any program's working dir. i'm filling up my shell's current 
working dir environment variable with calling it to able to use commands like 
clone of ls without any extra parameter. So for example when i invoke my 
listing program to see what is in my current working directory, it already 
knows that i'm in /usr/src from the CWD envoriment var.

> In most of the situations where you use syscalls, you can't avoid
> using them; the point is not to use them excessively.
> 
> E.g. if you're reading a file (or any other descriptor), calling
> read() a few times and reading a large amount of data each time is
> more efficient than calling read() lots of times and reading a small
> amount of data each time.
> 
> Or, for an "ls" replacement, only call stat() (or lstat()) if you
> actually need the additional data (e.g. for "ls -l", "ls -F" etc)
> rather than always calling it "just in case".

 Thank you, i've got the point completely.
 
> There is seldom any point in bypassing libc. For a syscall, the libc
> function will usually consist of the syscall itself, plus setting
> errno if the syscall returns an error status, so there wouldn't be
> anything to gain from making the syscall directly.

 Thank you very much for your advices and time :)


 Regards.
-- 


- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
 A. Murat Eren
 meren@comu.edu.tr, evreniz@core.gen.tr
 http://zion.comu.edu.tr/~evreniz/
 0x88FD9FC7, 
 910A FCB3 2AAB 4CA5 E4D9 EFFA 6555 A33A 88FD 9FC7
- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -

--
 free software is a matter of liberty,
 not price. to understand the concept,
 you should think of "free speech",
 not "free beer".
-

      reply	other threads:[~2004-04-08  8:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-04-07 16:50 [Fwd: Re: Implementing a file counter (like "ls | wc")] Luciano Moreira - igLnx
2004-04-07 16:54 ` John T. Williams
2004-04-07 22:29   ` Holger Kiehl
2004-04-08  0:06     ` A. Murat Eren
2004-04-08  1:01       ` John T. Williams
2004-04-08  4:39       ` Glynn Clements
2004-04-08  8:05         ` A. Murat Eren [this message]

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=200404081105.13485.meren@comu.edu.tr \
    --to=meren@comu.edu.tr \
    --cc=linux-c-programming@vger.kernel.org \
    /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.
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).