init: Safely restart services to avoid race conditions.

Previously, service restarts (either an explicit "restart", or a "stop,
start" pair) exhibited a race condition whereby the new (restarting)
service process was often spawned before the old (stopping) process had
terminated.  This may have resulted in the new service process failing to
acquire a limited resource (file lock, socket bind, etc.) that the old
process had not yet released.

Now, a stopping service remains in the SVC_RUNNING state until its exiting
process has been reaped by waitpid.  This prevents a "stop, start" sequence
from spawning a second service process before resources held by the first
are released.  This enables safe service restarts by stopping the service,
waiting for the old service process to terminate, and (only then) starting
the new service process.  In the event of "restarting" an already stopped
service, the previous behavior is maintained whereby the service is simply
started.

This scenario could be special-cased by the restart command, however, we
have observed instances where services are, unintentionally, stopped and
started "too quickly," and so simultaneous processes for the same service
should never be allowed.

Note that this commit alters the behaviors for explicit restarts of
critical and oneshot services.  Previously these serivces would simply be
restarted, whereas now, an explicit restart of a critical service counts as
a crash (which may result in a recovery reboot) and oneshot services go
into the disabled state.
init: Retain traditional restart behavior for critical and oneshot services.

Adds an SVC_RESTART state that's used for an explicit "restart" of a
running service.  This retains the traditional restart behavior for
critical and oneshot services (previously altered by 7e36edd8), whereby
these services are "simply restarted" instead of counting as a crash (for a
critical serivce) or going into the disabled state (for a oneshot service).
am 4e28e5b8: (-s ours) Reconcile with jb-mr1-release - do not merge

* commit '4e28e5b871e7a4d67297ece485c87680ba0f6021':
am 9d0e3dc8: am 6cc883ca: libusbhost: Fix possible missed "device added" notification

* commit '9d0e3dc89dc3f28a6d64daf996840c900010dcdc':
  libusbhost: Fix possible missed "device added" notification
am 85895980: am f4de0783: libusbhost: Fix USB device discovery on boot

* commit '85895980da0c2444f50779a45ec23b6bccc410f7':
  libusbhost: Fix USB device discovery on boot
am aaa1dfb5: am cba158a6: Merge "add command-line arguments to mkbootimg to move kernel, ramdisk, etc." into jb-mr1-dev

* commit 'aaa1dfb5d9bc1c9cd24abe00051e075ed6cd625d':
  add command-line arguments to mkbootimg to move kernel, ramdisk, etc.
am 7cc2be47: am b2b46dc4: Merge "Added a cmd for configuring number of video buffers for camera, if supported" into jb-mr1-dev

* commit '7cc2be476812bf3b4f3e4d51e6fc2a27bf4add6a':
  Added a cmd for configuring number of video buffers for camera, if supported
am 358641ec: (-s ours) Reconcile with jb-mr1-release - do not merge

* commit '358641ec1af9aa2b4f87e688f04e4836eccf2f20':
  add command-line arguments to mkbootimg to move kernel, ramdisk, etc.
am 91368bb1: am 60479afa: Merge changes I943b04dd,I645b6a2d into jb-mr1-dev

* commit '91368bb1c352dd00b8751b92cb1d6971e0143505':
  init: fix return value for android uid/gid check
  init.rc: make last_kmsg readable only by user system and group log
am 447e392b: (-s ours) Reconcile with jb-mr1-release - do not merge

* commit '447e392b6036aa9fcb9427782ab249921def8fc2':
am 1c237977: am a8afd723: Allow AID_BLUETOOTH to update persist.service.bdroid

* commit '1c237977e8f1b73bfd9bb873a0ba1ce61b75fcce':
  Allow AID_BLUETOOTH to update persist.service.bdroid
am 7391e7a4: (-s ours) Reconcile with jb-mr1-release - do not merge

* commit '7391e7a4e24c116a9aab66506f86757a2f7e74da':
Added clear command to toolbox

Change-Id: Ifb1b7693727997b94614f7da73081f0894ee88ad
am 2f096c3a: am f2e4d7ff: Merge "Native utils for working with user and app IDs." into jb-mr1-dev

* commit '2f096c3a96a715caaeb0746c8041e9dc9e62d6aa':
  Native utils for working with user and app IDs.
Merge "Added clear command to toolbox"
am b9c37922: am 1d421490: Merge "Include to define uid_t." into jb-mr1-dev

* commit 'b9c37922b7b445dc86c2c5eb3266c83bd88c5cb2':
  Include to define uid_t.
am 2fa85910: am e0346fa7: am b2a32cb9: am 8fb0caa7: Merge "config_mbr: Fix integer overflow"

* commit '2fa859101f9d5f568c2562b064e233b14973e6fc':
  config_mbr: Fix integer overflow
am 79737802: am 8268a75e: am c5db017c: am 63b2c577: Merge "Conditionally use SIGSTKFLT"

* commit '79737802421d7b32707f1c248b5ecb239965234a':
  Conditionally use SIGSTKFLT
am 211f9fb1: am 21c2c849: am b9994d22: am 8261d271: Merge "restorecon tombstone directory."

* commit '211f9fb14bb204044ce657c71a1d870b7ddcc0a0':
  restorecon tombstone directory.
am bdf4fd7a: am ff5c802e: am faad67fa: am ef3f7fa3: Merge "Set the SELinux security label on new directories."

* commit 'bdf4fd7a8c629eb7bef9f713ba7eb9cd4bd5ad32':
  Set the SELinux security label on new directories.