Use optparse style argument parsing.  Implement a 'wait-for-pid' option on xsend, to delay sending a message until after the specified process id exits
Use optparse style argument parsing. 
Implement a 'wait-for-pid' option on xsend, to delay sending a message
until after the specified process id exits

detrout/benderjab