File: run.sh

package info (click to toggle)
procdump 2.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 12,900 kB
  • sloc: cpp: 42,512; ansic: 4,610; sh: 1,447; makefile: 107; cs: 76
file content (39 lines) | stat: -rwxr-xr-x 866 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh

# Send a sleeper process into the background
sh -c "sleep 10" &
TASK_PID=$!
TASK_PGID=$(ps -o pgid= $TASK_PID)
echo "TASK PID = $TASK_PID"

# Procdump to kill the sleeper process. Needs root.
ls -l /usr/bin/procdump
procdump -pgid $TASK_PGID -n 1 &
PROCDUMP_PID=$!
echo "PROCDUMP PID = $PROCDUMP_PID"
ps aux | grep -i $PROCDUMP_PID

# Give procdump some time to do it's thing.
sleep 10

# Sleeper process may already be dead by this point
echo "Killing $TASK_PID"
kill -9 $TASK_PID 2>/dev/null

# This is to cleanup procdump if it is hanging
echo "Killing $PROCDUMP_PID"
kill -9 $PROCDUMP_PID 2>/dev/null

# Check if a core file has been created and clean it up
CORE_COUNT=$(ls -1 sh_time* | wc -l)
rm -f sh_time*
rm -f sleep_time*
echo "Cores dumped: $CORE_COUNT"

if [ $CORE_COUNT -gt 0 ]; then
	echo "Successful"
	exit 0
else
	echo "Failed"
	exit 1
fi