1#!/usr/bin/perl 2######################################################################### 3 4 #************************************************************** 5# 6# Licensed to the Apache Software Foundation (ASF) under one 7# or more contributor license agreements. See the NOTICE file 8# distributed with this work for additional information 9# regarding copyright ownership. The ASF licenses this file 10# to you under the Apache License, Version 2.0 (the 11# "License"); you may not use this file except in compliance 12# with the License. You may obtain a copy of the License at 13# 14# http://www.apache.org/licenses/LICENSE-2.0 15# 16# Unless required by applicable law or agreed to in writing, 17# software distributed under the License is distributed on an 18# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19# KIND, either express or implied. See the License for the 20# specific language governing permissions and limitations 21# under the License. 22# 23#************************************************************** 24 25 26 27#################################################################### 28# File Name: template.pl 29# Version : 1.0 30# Project : XMerge 31# Author : Brian Cameron 32# Date : 5th Sept. 2001 33# 34# 35# Takes x and y from the command line and taps the screen there. 36# Assumes pose is already running. 37# 38########################################################################## 39 40use POSIX "sys_wait_h"; # Need this for waitpid with WNOHANG 41use EmRPC; # EmRPC::OpenConnection, CloseConnection 42use EmFunctions; 43use EmUtils; 44 45if ($#ARGV != 0) 46{ 47 print "\nUsage: $0 timeout\n\n"; 48 exit -1; 49} 50 51$timeout = $ARGV[0]; 52 53if (!defined($up_pid = fork())) 54{ 55 print "ERROR, problem forking.\n" 56} 57elsif ($up_pid) 58{ 59 print "\nChecking to see if pose is started properly.\n"; 60 61 # Parent process 62 # 63 sleep($timeout); 64 65 waitpid($up_pid, WNOHANG); 66 67 if (kill(0, $up_pid)) 68 { 69 print "Pose did not start successfully...\n"; 70 kill(9, $up_pid); 71 exit(-1); 72 } 73 else 74 { 75 # The child process exited okay, so we know it will not 76 # hang...but the open_connection will just die if pose 77 # isn't started...so try it in the parent. 78 # 79 open_connection(); 80 close_connection(); 81 82 print "Verified pose started successfully...\n"; 83 exit(0); 84 } 85} 86else 87{ 88 # Child process - Try to open/close the connection. This 89 # can hang if pose did not start properly... 90 # 91 open_connection(); 92 close_connection(); 93} 94 95sub open_connection 96{ 97 print "opening connection\n"; 98 EmRPC::OpenConnection(6415, "localhost"); 99} 100 101sub close_connection 102{ 103 print "closing connection\n"; 104 EmRPC::CloseConnection(); 105} 106 107