<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Hitesh Sisara</title>
    <description>The latest articles on DEV Community by Hitesh Sisara (@hitesh_sisara).</description>
    <link>https://dev.to/hitesh_sisara</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4254980%2F7b99fd07-af1d-4353-a789-c687ab9449fe.png</url>
      <title>DEV Community: Hitesh Sisara</title>
      <link>https://dev.to/hitesh_sisara</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hitesh_sisara"/>
    <language>en</language>
    <item>
      <title>How a Claude Code session froze my Mac with a 288 GB text file</title>
      <dc:creator>Hitesh Sisara</dc:creator>
      <pubDate>Fri, 20 Nov 2026 06:07:45 +0000</pubDate>
      <link>https://dev.to/hitesh_sisara/how-a-claude-code-session-froze-my-mac-with-a-288-gb-text-file-2h0</link>
      <guid>https://dev.to/hitesh_sisara/how-a-claude-code-session-froze-my-mac-with-a-288-gb-text-file-2h0</guid>
      <description>&lt;p&gt;My Mac suddenly became unresponsive this morning. The disk was almost full, and one text file in &lt;code&gt;/tmp&lt;/code&gt; had grown to 288 GB in about 12 minutes.&lt;/p&gt;

&lt;p&gt;I run a lot of Claude Code sessions at once, so the first question was which one, if any, was writing it.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding the writer
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;lsof&lt;/code&gt; lists the processes that have a file open:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsof /tmp/qa/review-all.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It showed a &lt;code&gt;cat&lt;/code&gt; and a &lt;code&gt;grep&lt;/code&gt;. Walking up the parent chain with &lt;code&gt;ps -o pid,ppid,command -p &amp;lt;pid&amp;gt;&lt;/code&gt; led from both of them to shells started by the same Claude Code session.&lt;/p&gt;

&lt;h2&gt;
  
  
  The loop
&lt;/h2&gt;

&lt;p&gt;That session was running a design review over a set of pages. Each review wrote a small text file of findings, and the last step combined them into one file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for&lt;/span&gt; f &lt;span class="k"&gt;in&lt;/span&gt; /tmp/qa/review-*.txt&lt;span class="o"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"=== $(basename "&lt;/span&gt;&lt;span class="nv"&gt;$f&lt;/span&gt;&lt;span class="s2"&gt;")"&lt;/span&gt;
  cat &lt;span class="s2"&gt;"$f"&lt;/span&gt;
&lt;span class="k"&gt;done&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/qa/review-all.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output file is &lt;code&gt;review-all.txt&lt;/code&gt;, and that name also matches &lt;code&gt;review-*.txt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The redirect at the end applies to the whole loop, so the shell creates &lt;code&gt;review-all.txt&lt;/code&gt; before it expands the glob. The new, empty output file lands in the list of inputs. When the loop reaches it, &lt;code&gt;cat&lt;/code&gt; starts reading the file it is appending to. Every block it reads is written back onto the end, so the end of the file moves away as fast as &lt;code&gt;cat&lt;/code&gt; reads, and &lt;code&gt;cat&lt;/code&gt; never gets there.&lt;/p&gt;

&lt;p&gt;The one-line version has the same trap, with a delay:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;cat /tmp/qa/review-*.txt &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /tmp/qa/review-all.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here the glob is expanded before the redirect creates the file, so the first run is fine. On the second run the old &lt;code&gt;review-all.txt&lt;/code&gt; is one of the inputs, and the loop starts. Agents rerun commands all the time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Linux would have stopped it
&lt;/h2&gt;

&lt;p&gt;I ran the same loop on a Linux machine with GNU coreutils and got this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cat: review-all.txt: input file is output file
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;GNU &lt;code&gt;cat&lt;/code&gt; checks whether an input is the same file as its output and skips it. The &lt;code&gt;cat&lt;/code&gt; that ships with macOS comes from BSD and has no such check, so it keeps going until a write fails. Mine stopped on its own after 12 minutes, probably when a write failed for lack of space. By then the file held 288 GB, about 400 MB for every second it ran, and the disk was 96% full.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the agent made it worse
&lt;/h2&gt;

&lt;p&gt;The command ran into the agent's 10-minute command timeout, so the tool moved it to the background and the agent went on with other work. Two more full reads of the file followed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The original command ended with a &lt;code&gt;grep -c&lt;/code&gt; over the combined file to count the clean pages. That &lt;code&gt;grep&lt;/code&gt; had to read all 288 GB.&lt;/li&gt;
&lt;li&gt;A few minutes later the agent checked progress with &lt;code&gt;cat review-all.txt | wc -c&lt;/code&gt;, which reads every byte again just to count them.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Both were still running when I found the file. Neither changed it, but together they kept the disk busy reading hundreds of gigabytes. A person in a hurry could have written every one of these commands.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cleaning up
&lt;/h2&gt;

&lt;p&gt;Stop anything that still has the file open before you delete it. Deleting a file only removes its name; the space comes back when the last process holding it closes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;lsof /tmp/qa/review-all.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;kill&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;pid&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;rm /tmp/qa/review-all.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Free space went from 37 GiB back to 306 GiB.&lt;/p&gt;

&lt;h2&gt;
  
  
  Avoiding it
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Write the combined file somewhere the glob can't match, such as another folder or another extension (&lt;code&gt;&amp;gt; /tmp/qa/combined.md&lt;/code&gt;). Or skip it explicitly at the top of the loop: &lt;code&gt;[ "$f" = /tmp/qa/review-all.txt ] &amp;amp;&amp;amp; continue&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;To see how big a file is, use &lt;code&gt;ls -l&lt;/code&gt; or &lt;code&gt;stat&lt;/code&gt;. They read metadata. &lt;code&gt;cat file | wc -c&lt;/code&gt; reads the whole file. This is worth putting in the instructions you give your agents.&lt;/li&gt;
&lt;li&gt;Put a ceiling on file size in the shells your agents run. &lt;code&gt;ulimit -f&lt;/code&gt; kills a process with &lt;code&gt;SIGXFSZ&lt;/code&gt; when a file it writes passes the limit, and a generous limit still stops a runaway file long before the disk fills. The units differ between shells: zsh counts 512-byte blocks and bash counts 1 KB blocks, so &lt;code&gt;ulimit -f 200&lt;/code&gt; means 100 KB in zsh and 200 KB in bash.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>ai</category>
      <category>macos</category>
      <category>bash</category>
      <category>debugging</category>
    </item>
  </channel>
</rss>
