New script from Jude Nelson
authorSapan Bhatia <gwsapan@gmail.com>
Fri, 13 Jan 2012 22:36:42 +0000 (17:36 -0500)
committerSapan Bhatia <gwsapan@gmail.com>
Fri, 13 Jan 2012 22:36:42 +0000 (17:36 -0500)
exec/prox [new file with mode: 0755]

diff --git a/exec/prox b/exec/prox
new file mode 100755 (executable)
index 0000000..8d1654a
--- /dev/null
+++ b/exec/prox
@@ -0,0 +1,37 @@
+#!/usr/bin/python
+
+MAX_LOCKED_MEMSIZE = 1024 * 1024 * 1024  # 1 GB
+SHMMAX = 1024 * 1024 * 1024   # 1 GB
+
+SLICE = "princeton_vcoblitz"
+
+import os
+import sys
+import resource
+
+if __name__ == "__main__":
+
+   # expand lockable memory
+   resource.setrlimit( resource.RLIMIT_MEMLOCK, (MAX_LOCKED_MEMSIZE, MAX_LOCKED_MEMSIZE) )
+  
+   # ensure that shmmax is big enough.
+   os.system( "vspace -e " + SLICE + " --ipc sysctl -w kernel.shmmax=" + str(SHMMAX) )
+   
+   # we'll echo argv into the prox pipe
+   args = sys.stdin.read().split()
+
+   print "args = " + str(args)
+
+   pid = os.fork()
+   if pid == 0:
+      # child
+      print "child forked"
+
+      os.execv( args[0], args )
+      #os.execve( args[0], args, {'LD_LIBRARY_PATH': "/vservers/" + SLICE + "/lib:/vservers/" + SLICE + "/lib64:/vservers/" + SLICE + "/usr/lib:/vservers/" + SLICE + "/usr/lib64"} )
+
+   else:
+      # parent
+      print "pid = " + str(pid)
+      os.wait()
+      sys.exit(0)