ctdb-tool: Simplify "ctdb process-exists"
authorAmitay Isaacs <amitay@gmail.com>
Fri, 22 Jul 2016 07:31:07 +0000 (17:31 +1000)
committerAmitay Isaacs <amitay@samba.org>
Mon, 25 Jul 2016 19:29:44 +0000 (21:29 +0200)
Drop the PNN part of the argument, improve output.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
ctdb/tests/simple/07_ctdb_process_exists.sh
ctdb/tools/ctdb.c

index 83205aa07f622407a4d29326933c43a0996d54db..b7492a84f19b15c2e992b6a876acd0599f1fd4cf 100755 (executable)
@@ -46,7 +46,7 @@ pid="$out"
 echo "Checking for PID $pid on node $test_node"
 # set -e is good, but avoid it here
 status=0
-onnode 0 "$CTDB process-exists ${test_node}:${pid}" || status=$?
+try_command_on_node $test_node "$CTDB process-exists ${pid}" || status=$?
 echo "$out"
 
 if [ $status -eq 0 ] ; then
@@ -63,4 +63,4 @@ try_command_on_node $test_node 'echo $$'
 pid="$out"
 
 echo "Checking for PID $pid on node $test_node"
-try_command_on_node -v 0 "! $CTDB process-exists ${test_node}:${pid}"
+try_command_on_node -v $test_node "! $CTDB process-exists ${pid}"
index cbdfbc9f68c4a4d7f7e711a6a85f74286eb52e30..dd009762b5f26fb64db148fa928d9378e89adf8b 100644 (file)
@@ -423,22 +423,19 @@ fail:
  */
 static int control_process_exists(struct ctdb_context *ctdb, int argc, const char **argv)
 {
-       uint32_t pnn, pid;
+       pid_t pid;
        int ret;
        if (argc < 1) {
                usage();
        }
 
-       if (sscanf(argv[0], "%u:%u", &pnn, &pid) != 2) {
-               DEBUG(DEBUG_ERR, ("Badly formed pnn:pid\n"));
-               return -1;
-       }
+       pid = atoi(argv[0]);
 
-       ret = ctdb_ctrl_process_exists(ctdb, pnn, pid);
+       ret = ctdb_ctrl_process_exists(ctdb, options.pnn, pid);
        if (ret == 0) {
-               printf("%u:%u exists\n", pnn, pid);
+               printf("PID %u exists\n", pid);
        } else {
-               printf("%u:%u does not exist\n", pnn, pid);
+               printf("PID %u does not exist\n", pid);
        }
        return ret;
 }