From: "Dmitry V. Levin" <ldv@altlinux.org> To: ALT Devel discussion list <devel@altlinux.ru> Subject: Re: [devel] temporary file handling: questions Date: Wed, 11 Jun 2003 03:32:52 +0400 Message-ID: <20030610233252.GA7921@basalt.office.altlinux.org> (raw) In-Reply-To: <20030611031459.3c410e3a.bga@altlinux.ru> [-- Attachment #1: Type: text/plain, Size: 914 bytes --] On Wed, Jun 11, 2003 at 03:14:59AM +0400, Grigory Batalov wrote: > Если я правильно понимаю, fdopen/fclose используются, чтобы > "занять" файловый дескриптор потоком и предотвратить > немедленное удаление функцией unlink? Нет, неправильно. fdopen(3) использует передаваемый в качестве аргумента дескриптор. > Или fdopen/fclose приведены для примера потокового > ввода/вывода, и их можно опустить (например, мне достаточно > open/close)? В этом случае "оттягивать до последнего" > нужно вызов close(fd) ? Да, fdopen(3) приведён в качестве (реального) примера в случае, когда осуществляется чтение/запись во временный файл. Можно не использовать stdio и обойтись read(2)/write(2); в этом случае вместо fclose(3) будет вызов close(2). Главное - сделать unlink(2) как можно раньше, и обязательно до закрытия дескриптора файла. Следует избегать файловых операций с именем временного файла. -- ldv [-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2003-06-10 23:32 UTC|newest] Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-06-03 8:17 [devel] I: temporary file handling: C coding guideline Dmitry V. Levin 2003-06-03 9:15 ` Stanislav Ievlev 2003-06-10 23:14 ` [devel] temporary file handling: questions Grigory Batalov 2003-06-10 23:32 ` Dmitry V. Levin [this message] 2003-06-11 7:31 ` Alexey I. Froloff 2003-06-11 8:19 ` Dmitry V. Levin 2003-06-13 10:30 ` Alexey I. Froloff 2003-06-11 8:31 ` Stanislav Ievlev 2003-06-11 14:14 ` [devel] " Alexey Tourbin
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=20030610233252.GA7921@basalt.office.altlinux.org \ --to=ldv@altlinux.org \ --cc=devel@altlinux.ru \ /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