breakpad: Fix crash_reporter upload success handling on Chrome OS

Chrome OS incorrectly prints this message to the ui log after each crash:
"System crash-reporter failed to process crash report."
This makes it confusing to work on crash reporting, as crash_reporter is
actually succeeding.

The problem was how breakpad listens for the crash id / success string.
A helper process reads the crash id/status string from a pipe. That pipe
was connected to fd 3 via sys_dup2(). This worked on Linux because wget was
configured to write status to /dev/fd/3. This failed on Chrome OS because
crash_reporter writes status to stdout (fd 1).

This CL wires crash_reporter's output to stdout using sys_dup2(). It also
eliminates the dup2() code on Linux, because wget can write directly to
the pipe to the helper process.

I also pulled out some helper functions because the existing functions are
too long, and also added some docs and error checking.

BUG=688248
TEST=Navigate to chrome:inducebrowsercrashforrealz on chromebook, look at
/var/log/ui/ui.LATEST, see "Crash dump received by crash_reporter" log line.

Review-Url: https://codereview.chromium.org/2676023003
Cr-Commit-Position: refs/heads/master@{#448724}
1 file changed