From: "Slava Semushin" <slava.semushin@gmail.com> To: "ALT Devel discussion list" <devel@lists.altlinux.org> Subject: [devel] Нужно ли вызывать endpwent() после использования getpwuid() ? Date: Mon, 26 Feb 2007 16:32:03 +0300 Message-ID: <75e139a00702260532j7c90aec2gadf659ea0e5c1de3@mail.gmail.com> (raw) Здравствуйте! Листал тут на работе книжку от O'Reilly "Secure Programming Book for C and C++" и увидел такой пример: %% #include <sys/types.h> #include <stdio.h> #include <unistd.h> #include <pwd.h> int main(int argc, char *argv[]) { uid_t uid; struct passwd *pwd; uid = getuid(); printf("User's UID is %d.\n", (int)uid); if ( ! (pwd = getpwuid(uid))) { printf("Unable to get user's password file record!\n"); endpwent(); return 1; } printf("User's home directory is %s\n", pwd->pw_dir); endpwent(); return 0; } %% Собственно, привлёк внимание факт вызова endpwent(). Почитал ман к Линуксу, к Нетке, ещё каких-то в интернете и не очень понял, действительно ли нужно после вызова getpwuid() вызывать endpwent(). Пожалуйста, разъясните этот момент, ведь если я правильно понял, то невызов endpwent() чреват утечкой файлового дескриптора. Заранее спасибо! -- + Slava Semushin | slava.semushin @ gmail.com + ALT Linux Team | php-coder @ altlinux.ru
next reply other threads:[~2007-02-26 13:32 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2007-02-26 13:32 Slava Semushin [this message] 2007-02-26 13:44 ` Mikhail Gusarov 2007-02-26 13:49 ` Damir Shayhutdinov 2007-02-26 13:52 ` [devel] [SUMMARY][OFF]Re: " Slava Semushin 2007-02-26 13:56 ` [devel] " Dmitry V. Levin
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=75e139a00702260532j7c90aec2gadf659ea0e5c1de3@mail.gmail.com \ --to=slava.semushin@gmail.com \ --cc=devel@lists.altlinux.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
ALT Linux Team development discussions This inbox may be cloned and mirrored by anyone: git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \ devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru public-inbox-index devel Example config snippet for mirrors. Newsgroup available over NNTP: nntp://lore.altlinux.org/org.altlinux.lists.devel AGPL code for this site: git clone https://public-inbox.org/public-inbox.git