Closed Bug 1512686 Opened 6 years ago Closed 5 years ago

[mozdevice] Use pidof to test for process existence / get pid

Categories

(Testing :: Mozbase, enhancement, P1)

Version 3
enhancement

Tracking

(firefox66 fixed)

RESOLVED FIXED
mozilla66
Tracking Status
firefox66 --- fixed

People

(Reporter: gbrown, Assigned: gbrown)

References

Details

Attachments

(1 file, 1 obsolete file)

      No description provided.
Seems like it would be much more efficient than parsing ps output, when available.
Blocks: 1509324
Priority: -- → P1
In my testing, pidof is not available on the 4.3 emulator, but is available on all of our newer android versions.

https://treeherder.mozilla.org/#/jobs?repo=try&tier=1%2C2%2C3&revision=20c4becb37e5999405bb11fcd885c8008cbaa122
Attachment #9030051 - Flags: review?(bob)
Comment on attachment 9030051 [details] [diff] [review]
use 'adb shell pidof <package>' to determine process existence, where available

Review of attachment 9030051 [details] [diff] [review]:
-----------------------------------------------------------------

I like the use of pidof. Didn't know about it!

What would you think of adding a helper method pidof that is basically the meat of your addition to pkill and then calling that in both places?

::: testing/mozbase/mozdevice/mozdevice/adb.py
@@ +2437,5 @@
> +                pid_output = self.shell_output('pidof %s' % app, timeout=timeout)
> +            except ADBError:
> +                return False
> +            re_pid = re.compile(r'^[0-9]+$')
> +            match = re_pid.search(pid_output)

Won't this only match a single process id? If pidof returns more than one process id, won't this fail since it is anchored at the start and end?
Attachment #9030051 - Flags: review?(bob)
Comment on attachment 9030599 [details] [diff] [review]
use 'adb shell pidof <package>' to determine process existence, where available

Review of attachment 9030599 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks!
Attachment #9030599 - Flags: review?(bob) → review+
Pushed by gbrown@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/e977d545d16a
Use pidof to determine android process pid, when available; r=bc
https://hg.mozilla.org/mozilla-central/rev/e977d545d16a
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla66
Depends on: 1514363
See Also: → 1529960
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: