-
Notifications
You must be signed in to change notification settings - Fork 59
test-case: Implement one common method for kill process #1352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -945,6 +945,29 @@ check_alsa_tool_process() | |||||
| esac | ||||||
| } | ||||||
|
|
||||||
| kill_process() | ||||||
| { | ||||||
| local pid="$1" | ||||||
|
|
||||||
| [[ -n "$pid" ]] || { | ||||||
| dloge "kill_process: missing pid" | ||||||
| return 1 | ||||||
| } | ||||||
|
|
||||||
| kill -0 "$pid" 2>/dev/null || return 0 | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
https://stackoverflow.com/questions/3043978/how-to-check-if-a-process-id-pid-exists BTW there is still a race: the process could still exit right after this check. |
||||||
|
|
||||||
| kill -15 "$pid" 2>/dev/null || true | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Discarding stderr is almost always a bad idea. What unwanted message does this discard?
Suggested change
|
||||||
| sleep 1 | ||||||
|
|
||||||
| kill -0 "$pid" 2>/dev/null || return 0 | ||||||
|
|
||||||
| kill -9 "$pid" 2>/dev/null || true | ||||||
|
|
||||||
| kill -0 "$pid" 2>/dev/null && return 1 | ||||||
|
|
||||||
| return 0 | ||||||
| } | ||||||
|
|
||||||
| aplay_opts() | ||||||
| { | ||||||
| if [[ "$SOF_ALSA_TOOL" = "tinyalsa" ]]; then | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -137,6 +137,6 @@ do | |
| exit 1 | ||
| } | ||
| dlogi "Killing $cmd_args" | ||
| kill -9 $process_id || true | ||
| kill_process "$process_id" || true | ||
| done | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would
diehere because this looks like a serious enough bug.