summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-10 11:50:16 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-02-10 11:51:48 +0000
commit296866c38e1b88df42d66bdc32cfed2d5212914c (patch)
treef56631b4a7ed520ad4c7198c14a8746cc30cd01b /scripts
parentd3d236b2bf2784d7454dcb7fce595b6aac6967cd (diff)
downloadpoky-296866c38e1b88df42d66bdc32cfed2d5212914c.tar.gz
image-swab: Convert to attach strace to the process to obtain the required swabber data
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/swabber-strace-attach30
1 files changed, 30 insertions, 0 deletions
diff --git a/scripts/swabber-strace-attach b/scripts/swabber-strace-attach
new file mode 100755
index 0000000000..d4f80e4e91
--- /dev/null
+++ b/scripts/swabber-strace-attach
@@ -0,0 +1,30 @@
1#!/usr/bin/env python
2import os
3import sys
4
5# Detach from the controlling terminal and parent process by forking twice to daemonize ourselves,
6# then run the command passed as argv[1]. Send log data to argv[2].
7
8pid = os.fork()
9if (pid == 0):
10 os.setsid()
11 pid = os.fork()
12 if (pid != 0):
13 os._exit(0)
14else:
15 sys.exit()
16
17
18si = file(os.devnull, 'r')
19so = file(sys.argv[2], 'w')
20se = so
21
22# Replace those fds with our own
23os.dup2(si.fileno(), sys.stdin.fileno())
24os.dup2(so.fileno(), sys.stdout.fileno())
25os.dup2(se.fileno(), sys.stderr.fileno())
26
27ret = os.system(sys.argv[1])
28
29os._exit(ret)
30