Merge lp:~ev/apport/fsync-upstart-crashes into lp:apport

Proposed by Evan on 2012-11-20
Status: Merged
Merged at revision: 2534
Proposed branch: lp:~ev/apport/fsync-upstart-crashes
Merge into: lp:apport
Diff against target: 21 lines (+11/-0)
1 file modified
data/apport (+11/-0)
To merge this branch: bzr merge lp:~ev/apport/fsync-upstart-crashes
Reviewer Review Type Date Requested Status
Martin Pitt 2012-11-20 Approve on 2012-11-20
James Hunt (community) 2012-11-20 Approve on 2012-11-20
Review via email: mp+135134@code.launchpad.net

Description of the change

As discussed in the "Apport/Whoopsie and Upstart" email, we should fsync crashes of upstart.

To post a comment you must log in.
James Hunt (jamesodhunt) wrote :

Looks good to me.

review: Approve
Martin Pitt (pitti) wrote :

Thanks, looks fine!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/apport'
2--- data/apport 2012-07-12 15:11:48 +0000
3+++ data/apport 2012-11-20 12:16:25 +0000
4@@ -422,6 +422,17 @@
5 try:
6 info.write(reportfile)
7 if reportfile != sys.stderr:
8+ # Ensure that the file gets written to disk in the event of an
9+ # Upstart crash.
10+ if info.get('ExectuablePath', '') == '/sbin/init':
11+ reportfile.flush()
12+ os.fsync(reportfile.fileno())
13+ parent_directory = os.path.dirname(report)
14+ try:
15+ fd = os.open(parent_directory, os.O_RDONLY)
16+ os.fsync(fd)
17+ finally:
18+ os.close(fd)
19 reportfile.close()
20 except IOError:
21 if reportfile != sys.stderr:

Subscribers

People subscribed via source and target branches