<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Jun 17, 2014 at 12:24 AM, Lennart Poettering <span dir="ltr"><<a href="mailto:lennart@poettering.net" target="_blank">lennart@poettering.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="">On Mon, 16.06.14 21:32, Geunsik Lim (<a href="mailto:geunsik.lim@gmail.com">geunsik.lim@gmail.com</a>) wrote:<br>

<br>
> Hi all,<br>
><br>
> Recently, i checked that there are  some of the "close_all_fds" functions<br>
> as follows<br>
> Why we Systemd run this functions? Whey this functions need Systemd's<br>
> management?<br>
><br>
> invain@u1204lgs:/sandbox/tizentvfolder/systemd$ grep -R "close_all_fds" ./*<br>
> ./src/nspawn.c:                close_all_fds(NULL, 0);<br>
> ./src/util.c:int close_all_fds(const int except[], unsigned n_except) {<br>
> ./src/util.c:        close_all_fds(NULL, 0);<br>
> ./src/main.c:                close_all_fds(NULL, 0);<br>
> ./src/spawn-agent.c:                close_all_fds(NULL, 0);<br>
> ./src/execute.c:                err = close_all_fds(socket_fd >= 0 ?<br>
> &socket_fd : fds,<br>
> ./src/execute.c:                err = close_all_fds(fds, n_fds);<br>
> ./src/util.h:int close_all_fds(const int except[], unsigned n_except);<br>
<br>
</div>David is right, this is really just a safety net, and particularly<br>
useful when one of our tools is invoked from arbitrary code that might<br>
not be written cleanly.<br></blockquote><div><br></div><div>It seems that a goal of close_all_fds() is garbage collector to guarantee available file descriptors  for new fopen() system call.</div><div>Nowadays, the modern computer system is multi-process/multi-thread scheme more than single-process/multi-thread. </div>
<div>Does systemd have to care the number of "open file size"? Actually, Is this function need for safety net?  </div><div>For example,  </div><div><div><div>invain@u1204lgs:/opt/git-systemd$ ulimit  -n</div><div>
1024</div></div></div><div><br></div><div>If Systemd does not execute the close_all_fds() functions, </div><div>What will be happened in real environment?  </div><div><br></div><div>On the other hand, if systemd have to  not close more than two file descriptors(e.g. 5, 17, 19) for some case to release Linux distribution </div>
<div>based on Systemd, can we use close_all_fds(except, ***)? In this case, Do we have to specify  withclose_all_fds(except, 3 + 19)?</div><div><br></div><div>Thanks,</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

<div class=""><div class="h5"><br>
Lennart<br>
<br>
--<br>
Lennart Poettering, Red Hat<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>----</div><div>Best regards,</div><div>Geunsik Lim, Samsung Electronics</div><div><a href="http://leemgs.fedorapeople.org" target="_blank">http://leemgs.fedorapeople.org</a></div>
<div>----</div><div>To unsubscribe from this list: send the line "unsubscribe linux-kernel" in</div><div>the body of a message to <a href="mailto:majordomo@vger.kernel.org" target="_blank">majordomo@vger.kernel.org</a></div>
<div>More majordomo info at  <a href="http://vger.kernel.org/majordomo-info.html" target="_blank">http://vger.kernel.org/majordomo-info.html</a></div><div>Please read the FAQ at  <a href="http://www.tux.org/lkml/" target="_blank">http://www.tux.org/lkml/</a></div>

</div></div>