<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Dec 21, 2021 at 2:34 AM Petr Vorel <<a href="mailto:pvorel@suse.cz">pvorel@suse.cz</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">Hi Li,<br>
<br>
>     v2 --> v3<br>
>       * rename to tst_disable_oom_protection<br>
>       * support set PID as 0 to protect current process<br>
<br>
> +static void set_oom_score_adj(pid_t pid, int value)<br>
> +{<br>
> +     int val;<br>
> +     char score_path[64];<br>
> +<br>
> +     if (access("/proc/self/oom_score_adj", F_OK) == -1) {<br>
We need to check here also /proc/PID/oom_score_adj, i.e. score_path.<br></blockquote><div><br></div><div><div class="gmail_default" style="font-size:small">Good catch, I would add a 'W_OK' checking and skip the setting with</div><div class="gmail_default" style="font-size:small">a reminder message if run without root.</div><br></div><div><div class="gmail_default" style="font-size:small">how about this?</div><br></div><div class="gmail_default" style="font-size:small">if (access(score_path, W_OK) == -1) {</div>          <span class="gmail_default" style="font-size:small">        </span>tst_res(TINFO, "Warning: %s cannot be accessed for writing,<br>                       <span class="gmail_default" style="font-size:small">                </span>please check if test run with root user.",<br>                    <span class="gmail_default" style="font-size:small">                </span>score_path);<br>               <span class="gmail_default" style="font-size:small">        </span>return<br> }<br><div class="gmail_default" style="font-size:small"><br></div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Regards,<br></div><div>Li Wang<br></div></div></div></div>