среда, 17. јун 2020., Ahmed Karaman <ahmedkhaledkara...@gmail.com> је
написао/ла:

> On Wed, Jun 17, 2020 at 7:35 PM Alex Bennée <alex.ben...@linaro.org>
> wrote:
> >
> > Right - which I do as a developer. It would be rude to sudo things if
> > you don't need to because then you end up running your potentially
> > un-trusted application with root privileges.
> >
> > Could we either probe for the requirement or require an explicit sudo
> > flag which we can prompt for if it fails?
> >
> To make sure I got it right. You mean I should specify in the script
> comment on the top that the user should modify the
> kernel.perf_event_paranoid setting in order to run the script, otherwise,
> they should add a --sudo flag when running the Python script to invoke
> perf as sudo?
>
>
I think Alex meant that everything related to super user access should be
examined by the script. You could:

A. Establish if the user that execute the script is already super user. If
yes, you can proceed with command lines containing "perf. (see hints how to
do this here:
https://stackoverflow.com/questions/2806897/what-is-the-best-way-for-checking-if-the-user-of-a-script-has-root-like-privileg
)

B. Establish if "perf" can be executed successfully with current user
privelages. If yes, you can also proceed with command lines containing
"perf" (a primitive but simple way for establishing this is to run "perf
stat ls /" and see what happens, success or error)

C. If neither A nor B are satisfied, you cold emit error message
instructing the user what he needs to/could do.

Just my 2 c. Not sure if this is compatible with Alex' thoughts.

Aleksandar


> > >
> > >> Also redirecting just stderr? why?
> > >
> > > Perf, as well as Valgrind, print their output on stderr not stdout.
> >
> > Right so I think a bit of splitting apart and use of subprocess can make
> > this cleaner and not involve quite so much being done with shell
> > redirection in one invocation.
> >
>
> Noted!
>

Reply via email to