1#!/usr/bin/env python
2#
3#   (C) 2001 by Argonne National Laboratory.
4#       See COPYRIGHT in top-level directory.
5#
6
7import sys, os, socket
8
9manPort = int(sys.argv[1])
10manSock = socket.socket()
11manSock.connect((socket.gethostname(),manPort))
12msg = manSock.recv(3)    # 'go\n'
13if not msg.startswith('go'):
14    print 'mpscliwrap: invalid go msg from man'
15    sys.exit(-1)
16
17try:     max_fds = os.sysconf('SC_OPEN_MAX')
18except:  max_fds = 1024
19for fd in range(3,max_fds):
20    try:     os.close(fd)
21    except:  pass
22# can NOT use syslog (including inside an mpd_print) below here without
23# doing a new openlog because any syslog fd would have been closed
24
25os.execvpe(sys.argv[2],sys.argv[3:],os.environ)    # client
26