#!/usr/bin/perl
#
# Copyright 2006 VMware, Inc.  All rights reserved.
#
# vmkping:
#    Wrapper script for the vmkernel TCP/IP stack ping utility.
#
# Note:
#    vmkping automatically switches to the vmkernel TCP/IP
#    stack, so '-i vmktcp' shouldn't be specified.
#

#Temporary fix for bug 99718: vmkload_app puts STDIN and friends
#in non-blocking mode.

use Fcntl;

my @fds = (STDIN, STDOUT, STDERR);
my @flags = map fcntl($_, F_GETFL, 0), @fds;
my @cmd = ("/usr/lib/vmware/bin/vmkload_app", "/usr/lib/vmware/bin/vmkping", @ARGV);
system @cmd;

map {fcntl($_, F_SETFL, int(shift @flags)) || print "vmkping: Failed to restore blocking mode on $_:$!\n";}  @fds;
