ps exits when gets the signal SIGPIPE

ps's output is sometimes redirected into a socket (ex: bugreport). If
that socket is then closed, ps gets a SIGPIPE and crashes, resulting
in a tombstone.  It is better that ps just exits gracefully instead.

Change-Id: Id5bf73f626580dca2ab03b6f12a444be1640407c
Reviewed-on: http://gerrit.pcs.mot.com/537642
SLT-Approved: Slta Waiver <sltawvr@motorola.com>
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Klocwork kwcheck <klocwork-kwcheck@sourceforge.mot.com>
Reviewed-by: Xue-Ying Hou <a16543@email.mot.com>
Reviewed-by: John Michelau <w14107@motorola.com>
Reviewed-by: Xin Guan <a18772@motorola.com>
Reviewed-by: David Ding <dding@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
utils: add realtime scheduling priority

Some threads in the framework or HALs do a small amount of work but have
latency requirements which cause a poor user experience if not satisfied
Even though these threads are prioritized higher than most other threads
in the system, their execution can still be delayed for several
milliseconds while a lower priority thread finishes its scheduler time
slice. Allow these threads to use the realtime scheduler by setting
their priority to ANDROID_PRIORITY_REALTIME

Ported from (CR)

Change-Id: Iebbfdc35c48381add9ae44b22d10f5b7049b1fab
Reviewed-on: http://gerrit.pcs.mot.com/569887
SLTApproved: Slta Waiver <sltawvr@motorola.com>
Reviewed-by: Russell Knize <rknize2@motorola.com>
Reviewed-by: Patrick Auchter <auchter@motorola.com>
Submit-Approved: Jing Ji <a5705c@motorola.com>
Tested-by: Jing Ji <a5705c@motorola.com>
Reviewed-by: Barry D Jordan <bjordan@motorola.com>
Reviewed-by: Stephen Rossbach <rossbach@motorola.com>
cutils: realtime scheduler class support

In order for Android processes to really take advantage of Linux's
real-time scheduler, set_sched_policy() needs to expose this
capability.  Real-time priorities are set via the sched_setscheduler()
API rather than setpriority().  We currently schedule them as benignly
as possible (using priority 1 and round-robin scheduling).

Signed-off-by: Fred Fettinger <fred.fettinger@motorola.com>
(cherry picked from commit 68ed2ae76acb3db24f61a093cdea7d17e269d9a7)

Change-Id: I99e845265bc63babdfb3720181b3d36308cb0c28
init: device: fix memory leak issue

Fix some memory leak and null pointer issues reported by KW.

Change-Id: I61df734380498b68cdb4c3f66dcf5771e9e191eb
Signed-off-by: Hong-Mei Li <a21834@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/549753
SLT-Approved: Slta Waiver <sltawvr@motorola.com>
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Patrick Auchter <auchter@motorola.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
(cherry picked from commit dab2f49656556281f8e8ac313c7023355f705489)
init: Fix several memory leaks

1. Fix fd leak in do_mount function
2. Fix file1 and file2 leak in process_firmware_event function

Change-Id: Ic4271f2cf5e1df3cd32265544764a22b42271213
Signed-off-by: Hong-Mei Li <a21834@motorola.com>
Reviewed-on: http://gerrit.pcs.mot.com/563988
SLTApproved: Slta Waiver <sltawvr@motorola.com>
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Yi-Wei Zhao <gbjc64@motorola.com>
SLTApproved: Yi-Wei Zhao <gbjc64@motorola.com>
Reviewed-by: Sheng-Zhe Zhao <a18689@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
(cherry picked from commit 0f13608cf4d753e494ea5ba848bdd67dcf59c317)
Handle SIGPIPE gracefully in logcat

logcat's output is sometimes redirected into a socket (ex: bugreport).
If that socket is then closed, logcat gets a SIGPIPE and crashes,
resulting in a tombstone.  Since this is a normal case, a tombstone is
not warranted.  It should just exit gracefully instead.

Change-Id: Ic2d2eca035f4b8a22778763d81932a064aeef5a5
Reviewed-on: http://gerrit.pcs.mot.com/536586
SLT-Approved: Slta Waiver <sltawvr@motorola.com>
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Klocwork kwcheck <klocwork-kwcheck@sourceforge.mot.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
Handle SIGPIPE gracefully in top

top's output is sometimes redirected into a socket (ex: bugreport).
If that socket is then closed, top gets a SIGPIPE and crashes,
resulting in a tombstone.  Since this is a normal case, a tombstone is
not warranted.  It should just exit gracefully instead.

Change-Id: I0087401af36bfc72446d58b3043251ccd6884eda
Reviewed-on: http://gerrit.pcs.mot.com/536587
SLT-Approved: Slta Waiver <sltawvr@motorola.com>
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Klocwork kwcheck <klocwork-kwcheck@sourceforge.mot.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
init.rc: surfaceflinger: use min realtime sched priority

Use the rlimit service option to allow surfaceflinger to use the
minimum realtime scheduler priority. Surfaceflinger uses this priority
to minimize latency of vsync events.

Change-Id: Id3eec568a64d8957f1748eeee11abf92f29ab083
Reviewed-on: http://gerrit.pcs.mot.com/550181
SLT-Approved: Slta Waiver <sltawvr@motorola.com>
Tested-by: Jira Key <jirakey@motorola.com>
Reviewed-by: Christopher Fries <c.fries@motorola.com>
Reviewed-by: Patrick Auchter <auchter@motorola.com>
Reviewed-by: Klocwork kwcheck <klocwork-kwcheck@sourceforge.mot.com>
Reviewed-by: Jeffrey Carlyle <jeff.carlyle@motorola.com>
Reviewed-by: Stephen Rossbach <ccpm12@motorola.com>
Submit-Approved: Jira Key <jirakey@motorola.com>
(cherry picked from commit 7d8919c0ceac940ce71ab49ba3d672b147ba5058)