<div dir="ltr"><br><br><div class="gmail_quote">On Mon, Mar 19, 2012 at 12:20 PM, Nadav Har'El <span dir="ltr"><<a href="mailto:nyh@math.technion.ac.il">nyh@math.technion.ac.il</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Mon, Mar 19, 2012, Erez D wrote about "Re: what happens if":<br>
<div class="im">> my reason for fork is only for exec() - to protect the first program from<br>
> the other.<br>
<br>
</div>Then you should be all fine.<br>
<div class="im"><br>
> the problem that may arise in forking a multithreaded is that one thread<br>
> may lock a mutex and then another call for fork, which means that the child<br>
> inherits the locked mutex.<br>
> i do not know internaly what library function use this mutex, e.g. will<br>
> close() need this mutex ? will dup() will ? in this case, trying to close a<br>
> side of a pipe, duping it or even closing open fds (for security issues)<br>
> may hang the child while the library waits for the mutex , and no other<br>
> thread exists in the child to release it<br>
<br>
</div>If you're talking about the C language, you won't have any of these<br>
problems. System calls like close() or dup() do not use any pthread<br>
capabilities like mutexes.<br>
<br>
If you're talking about a different programming language, I frankly<br>
have no idea what its fork() does. Maybe you need to write some C<br>
code that does fork()/exec() in one function call, and avoid this risk.<br></blockquote><div>i will be using C++. are you sure this is safe ? <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Did actually notice any problem with your code, or is this question<br>
just theoretical?<br></blockquote><div>theoretical <br></div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im"><br>
--<br>
Nadav Har'El | Monday, Mar 19 2012,<br>
<a href="mailto:nyh@math.technion.ac.il">nyh@math.technion.ac.il</a> |-----------------------------------------<br>
</div>Phone <a href="tel:%2B972-523-790466" value="+972523790466">+972-523-790466</a>, ICQ 13349191 |If God had intended us to be vegetarians,<br>
<a href="http://nadav.harel.org.il" target="_blank">http://nadav.harel.org.il</a> |He wouldn't have made animals out of meat<br>
</blockquote></div><br></div>