<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="29166" data-post-id="29166">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="sasajuric" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sasajuric/120/991_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  sasajuric
                  </h3>
		          </div>
						
			          <div class="user-title">
									<span>Author of Elixir In Action</span>
			          </div>
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<aside class="quote no-group" data-username="pdawczak" data-post="11" data-topic="1822">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/pdawczak/48/1507_2.png" class="avatar"> pdawczak:</div>
<blockquote>
<p>This is the bit I wasn’t sure - because iex session is killed (this is what happens with Ctrl-C + Ctrl-C, right?) does Elixir have time to send EOF?</p>
</blockquote>
</aside>
<p>I’m not really familiar with details, but I’m pretty certain Elixir (or rather BEAM) doesn’t need to send EOF at all. I assume that BEAM OS process owns its end of the pipes, so regardless of how BEAM OS process terminates, all its resources are closed, and the external program gets EOF when it attempts a read from its stdin. For this to happen instantaneously, the external program needs to constantly read from the pipe. If the program is busy with some other processing, it might take a long time to notice EOF. I’ve seen this situation in practice.</p>
<aside class="quote no-group" data-username="pdawczak" data-post="11" data-topic="1822">
<div class="title">
<div class="quote-controls"></div>
<img alt="" width="24" height="24" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/pdawczak/48/1507_2.png" class="avatar"> pdawczak:</div>
<blockquote>
<p>As mentioned earlier, wrapping with script was causing problem of not propagating it stopped</p>
</blockquote>
</aside>
<p>Ports are meant to be used with external programs which are written for to be used by them. If the program you’re using is not written for Erlang ports, you need some kind of an adapter which can handle all requirements of Erlang ports. That also means that your wrapper needs to detect the crash of the wrapped external program, and react to it by stopping itself, which should then be detectable on Elixir side of things. I never did this myself, so not sure how it can be done, but I’d be surprised if this wasn’t possible.</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="29166" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/graceful-shutdown-of-genservers/1822/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-29166" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="29166"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>