]>
Commit | Line | Data |
---|---|---|
0e47827d DB |
1 | #!/bin/bash |
2 | ||
3 | # Start a systemtap server | |
4 | # | |
aeb9cc10 | 5 | # Copyright (C) 2008-2011 Red Hat Inc. |
0e47827d DB |
6 | # |
7 | # This file is part of systemtap, and is free software. You can | |
8 | # redistribute it and/or modify it under the terms of the GNU General | |
9 | # Public License (GPL); either version 2, or (at your option) any | |
10 | # later version. | |
11 | ||
12 | # This script attempts to start a systemtap server and echoes the | |
13 | # process id, if successful. | |
14 | ||
98f552c2 | 15 | # Initialize the environment |
961588fd DB |
16 | . ${PKGLIBEXECDIR}stap-env |
17 | ||
e91c276f | 18 | startup_timeout=10 |
21325e0c | 19 | |
0e47827d | 20 | # start the server |
aeb9cc10 | 21 | ${stap_pkglibexecdir}stap-serverd "$@" </dev/null >/dev/null 2>/dev/null & |
0e47827d DB |
22 | server_pid=$! |
23 | ||
d5658775 | 24 | # Make sure the server is started |
03914a01 | 25 | for ((attempt=0; $attempt < $startup_timeout; ++attempt)) |
d5658775 | 26 | do |
98f552c2 | 27 | # Has the server started? |
7901b115 DB |
28 | if ! (ps -e | grep stap-serverd | grep $server_pid) >/dev/null 2>&1; then |
29 | sleep 1 | |
30 | continue | |
64aa100f | 31 | fi |
7901b115 | 32 | |
524d562b DB |
33 | # The server is ready |
34 | echo $server_pid | |
35 | exit 0 | |
d5658775 | 36 | done |
0e47827d | 37 | |
524d562b | 38 | echo -n "Unable to start a systemtap server: " >&2 |
e91c276f | 39 | echo "${stap_pkglibexecdir}stap-serverd did not start" >&2 |
7901b115 | 40 | |
524d562b | 41 | exit 1 # server did not start |