<div dir="ltr">LGTM, pushed.<div><br></div><div><a href="http://git.yoctoproject.org/cgit/cgit.cgi/ptest-runner2/commit/?id=fb93c99e1e771a8ada0476b76da6f2ba665e03ba">http://git.yoctoproject.org/cgit/cgit.cgi/ptest-runner2/commit/?id=fb93c99e1e771a8ada0476b76da6f2ba665e03ba</a><br></div><div><br></div><div>Thanks!,</div><div>Anibal</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, 31 May 2019 at 12:53, Randy MacLeod <<a href="mailto:randy.macleod@windriver.com">randy.macleod@windriver.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Thanks Sakib.<br>
<br>
Next time please use --prefix to add the ptest-runner tag:<br>
so you'll have a subject line like:<br>
<br>
[meta-oe][ptest-runner] utils.c: close all file descriptors after <br>
completing a ptest<br>
<br>
The subject line is wrongg since we are closing the fds<br>
*before* the tests. Resend with something like:<br>
  utils.c: close all fds in child for each ptest<br>
<br>
<br>
Wait to see if Anibal has any comment then send a v2<br>
with a 'v2' prefix in the subject like:<br>
  [yocto] [ptest-runner][PATCHv2 1/3] Makefile: libcheck now requires <br>
to link subunit<br>
<br>
Thanks,<br>
../Randy<br>
<br>
On 5/31/19 1:44 PM, Sakib Sajal wrote:<br>
> vredir ptest fails since too many file descriptors were open.<br>
> <br>
>Â From the failed ptest log:<br>
>Â Â Â run-vredir<br>
>Â Â Â 87,88c87,88<br>
>Â Â Â < ./vredir6.sub: line 10: /dev/null: Too many open files<br>
>Â Â Â < ./vredir6.sub: line 13: /dev/null: Too many open files<br>
>Â Â Â FAIL: run-vredir<br>
> <br>
> Added function to close file descriptors before starting a new process.<br>
> <br>
> Signed-off-by: Sakib Sajal <<a href="mailto:sakib.sajal@windriver.com" target="_blank">sakib.sajal@windriver.com</a>><br>
> Signed-off-by: Randy Macleod <<a href="mailto:randy.macleod@windriver.com" target="_blank">randy.macleod@windriver.com</a>><br>
> ---<br>
>Â Â utils.c | 19 +++++++++++++++++++<br>
>Â Â 1 file changed, 19 insertions(+)<br>
> <br>
> diff --git a/utils.c b/utils.c<br>
> index 504df0b..05c2bfe 100644<br>
> --- a/utils.c<br>
> +++ b/utils.c<br>
> @@ -28,6 +28,7 @@<br>
>Â Â #include <fcntl.h><br>
>Â Â #include <time.h><br>
>Â Â #include <dirent.h><br>
> +#include <sys/resource.h><br>
>Â Â #include <sys/types.h><br>
>Â Â #include <sys/wait.h><br>
>Â Â #include <sys/stat.h><br>
> @@ -240,6 +241,23 @@ filter_ptests(struct ptest_list *head, char **ptests, int ptest_num)<br>
>Â Â Â Â return head_new;<br>
>Â Â }<br>
>Â Â <br>
> +/* Close all fds from 3 up to 'ulimit -n'<br>
> + * i.e. do not close STDIN, STDOUT, STDERR.<br>
> + * Typically called in in a child process after forking<br>
> + * but before exec as a good policy especially for security.<br>
> + */<br>
> +static void<br>
> +close_fds(void)<br>
> +{<br>
> +Â Â Â struct rlimit curr_lim;<br>
> +Â Â Â getrlimit(RLIMIT_NOFILE, &curr_lim);<br>
> +<br>
> +Â Â Â int fd;<br>
> +Â Â Â for (fd=3; fd < curr_lim.rlim_cur; fd++) {<br>
> +Â Â Â Â Â Â Â (void) close(fd);<br>
> +Â Â Â }<br>
> +}<br>
> +<br>
>Â Â static inline void<br>
>Â Â run_child(char *run_ptest, int fd_stdout, int fd_stderr)<br>
>Â Â {<br>
> @@ -252,6 +270,7 @@ run_child(char *run_ptest, int fd_stdout, int fd_stderr)<br>
>Â Â Â Â dup2(fd_stdout, STDOUT_FILENO);<br>
>Â Â Â Â // XXX: Redirect stderr to stdout to avoid buffer ordering problems.<br>
>Â Â Â Â dup2(fd_stdout, STDERR_FILENO);<br>
> +Â Â Â close_fds();<br>
>Â Â Â Â execv(run_ptest, argv);<br>
>Â Â <br>
>Â Â Â Â exit(1);<br>
> <br>
<br>
<br>
-- <br>
# Randy MacLeod<br>
# Wind River Linux<br>
</blockquote></div>