<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>File I/O on Nalar</title>
    <link>https://nalar.dev/tags/file-i/o/</link>
    <description>Recent content in File I/O on Nalar</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Fri, 04 Sep 2026 00:00:00 +0700</lastBuildDate>
    <atom:link href="https://nalar.dev/tags/file-i/o/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Understand Linux File Descriptor Duplication and Shell Redirection</title>
      <link>https://nalar.dev/understand-linux-file-descriptor-duplication-and-shell-redirection/</link>
      <pubDate>Fri, 04 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/understand-linux-file-descriptor-duplication-and-shell-redirection/</guid>
      <description>&lt;p&gt;Shell redirection looks compact:&lt;/p&gt;&#xA;&lt;div&#xA;  x-data=&#34;{ code: $el.querySelector(&#39;code&#39;).innerText, copied: false }&#34;&#xA;  class=&#34;code-block group relative my-6 overflow-hidden rounded-xl border border-line bg-surface-muted dark:border-night-line dark:bg-night-surface&#34;&gt;&#xA;  &lt;button&#xA;    type=&#34;button&#34;&#xA;    @click=&#34;navigator.clipboard.writeText(code); copied = true; setTimeout(() =&gt; copied = false, 1600)&#34;&#xA;    class=&#34;absolute right-3 top-3 z-10 rounded-lg border border-line-strong bg-surface px-2 py-1 font-mono text-[0.65rem] text-muted opacity-0 transition group-hover:opacity-100 hover:bg-ink hover:text-white dark:border-night-line dark:bg-night dark:text-night-muted dark:hover:bg-white dark:hover:text-ink&#34;&gt;&#xA;    &lt;span x-text=&#34;copied ? &#39;Copied&#39; : &#39;Copy&#39;&#34;&gt;&lt;/span&gt;&#xA;  &lt;/button&gt;&#xA;  &#xA;  &lt;div class=&#34;overflow-x-auto p-4 text-sm leading-6 [&amp;_pre]:!m-0 [&amp;_pre]:!bg-transparent [&amp;_pre]:!p-0 [&amp;_code]:font-mono&#34;&gt;&#xA;    &lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;command &amp;gt;output.log 2&amp;gt;&amp;amp;1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&#xA;  &lt;/div&gt;&#xA;&lt;/div&gt;&#xA;&lt;p&gt;But that syntax hides a useful systems concept. The shell is not asking the command to &amp;ldquo;log somewhere else.&amp;rdquo; It is changing the command&amp;rsquo;s &lt;strong&gt;file descriptors&lt;/strong&gt; before the program starts.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Use Callable-Sentinel Iteration for Chunked Reads in Python</title>
      <link>https://nalar.dev/use-callable-sentinel-iteration-for-chunked-reads-in-python/</link>
      <pubDate>Fri, 04 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/use-callable-sentinel-iteration-for-chunked-reads-in-python/</guid>
      <description>&lt;p&gt;Reading a file in chunks is a small problem that appears in many larger tasks: hashing uploads, copying large files, parsing binary records, compressing streams, and sending data without loading everything into memory.&lt;/p&gt;&#xA;&lt;p&gt;A common solution is a &lt;code&gt;while&lt;/code&gt; loop that reads one chunk, checks for end-of-file, processes the chunk, and repeats. That loop is correct when written carefully, but Python has another standard-library pattern that expresses the same control flow as iteration:&lt;/p&gt;</description>
    </item>
    <item>
      <title>Write Files Atomically on Linux with rename and fsync</title>
      <link>https://nalar.dev/write-files-atomically-on-linux-with-rename-and-fsync/</link>
      <pubDate>Fri, 04 Sep 2026 00:00:00 +0700</pubDate>
      <guid>https://nalar.dev/write-files-atomically-on-linux-with-rename-and-fsync/</guid>
      <description>&lt;p&gt;Updating a small file looks simple: open it, truncate it, write the new contents, and close it. That works when nothing interrupts the write.&lt;/p&gt;&#xA;&lt;p&gt;The failure mode appears when a process crashes, the machine loses power, or another process reads the file while it is being rewritten. A reader can observe an empty or partially written file, and a crash can leave the pathname referring to incomplete data.&lt;/p&gt;&#xA;&lt;p&gt;For configuration files, state snapshots, generated metadata, and similar single-file updates, a better pattern is to write a complete replacement beside the original file and then rename it into place.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
