4 import fishdescriptor.fish
11 fishdescriptor <pid> <action>... [-p|--pid <pid> <action>...]
15 fish the openfile referenced by descriptor <there-fd> in
16 (the most recent) <pid> and keep a descriptor onto it;
17 and, optionally, give it the number <here> for exec
18 exec <program> [<arg>...]
19 execute a process with each specified numeric <here>
22 calls getsockname/getpeername on the most recent
26 now attach to <pid>, detaching from previous pid
29 def set_donor(pid_arg):
31 if donor is not None: donor.detach()
32 donor = fishdescriptor.fish.Donor(pid)
35 def arg_matches(regexp):
37 m = re.search(regexp, arg)
44 while arg_ix < len(sys.argv):
46 if arg_matches(r'^-p(\d+)') or
47 arg_matches(r'^--pid=(\d+)$')
48 set_donor(m.groups(1)[0])
51 (?:-p|^--pid(?:=|$))(\d*)$'):
53 pid = int(m.groups(1)[0])
54 elif arg_matches(r'^(?:-p|^--pid=)(\d+)$'):
59 elif arg_matches(r'\d+
61 parser = OptionParser(usage=usage, )
63 parser.add_option("-p", "--pid", type='int', callback=set_donor)
66 pid = int(sys.argv[1])
67 fds = [int(x) for x in sys.argv[2:]]
69 d = fishdescriptor.fish.Donor(pid)