how to automate kill PIDs to solve `Could not claim the USB device`?

br flag

I have the same problem in this link, but the problem is I want to automate this process in an executable file, without the need to kill first PIDs every time. in fact, I want my executable file to detect these PIDs each time, and then kill them if necessary.

Do you have any idea how to do so?

Will avatar
id flag
Probably best to clarify your problem in its entirety rather than just post a link to a similar problem - it'll be easier for people to see what your issue is without having to visit more than one page.
kz flag

Bash script I wrote for me when I had this problem:

kill_args=$(pgrep gphoto)
  if [-z  $kill_args]; then

    echo "Arguments are:: $( pgrep gphoto )"
    pgrep gphoto | xargs kill
    echo "No gphoto process"

This script Kills all active gphoto processes. I am uncertain if that will help in you bcase.

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.