title: NSTask with multiple pipe input
body: <p>I'm trying to use pipes to handle a command that requires multiple inputs, but not quite sure how to do it. Here's a snippet of what I'm trying to do. I know how to handle the first input, but I'm at lost as to piping in the second input <code>-newstdinpass</code></p>
  
  <pre><code>NSTask *task = [[NSTask alloc] init];
  NSPipe *pipe = [NSPipe pipe];
  
  [task setLaunchPath: @"/bin/sh"];
  [task setArguments: [NSArray arrayWithObjects: @"-c", @"/usr/bin/hdiutil chpass -oldstdinpass -newstdinpass /path/to/dmg", nil]];
  [task setStandardInput:pipe];
  [task launch];
  
  [[pipe fileHandleForWriting] writeData:[@"thepassword" dataUsingEncoding:NSUTF8StringEncoding]];
  [[pipe fileHandleForWriting] closeFile];
  
  [task waitUntilExit];
  [task release];
  </code></pre>
  
  <p>So I know using <code>hdiutil</code> in this manner is a bit of a hack, but in terms of pipes, am I going about it the correct way?</p>
  
  <p>Thanks.</p>
  
  <p><strong>UPDATE</strong>: In case others are wondering about this, a quick solution to my problem is to pass in a null-terminated string as Ken Thomases had pointed out below. Use <code>[[NSString stringWithFormat:@"oldpass\0newpass\0"] dataUsingEncoding:NSUTF8StringEncoding]</code> into the pipe. Now, still need to learn how to bridge multiple <code>NSTasks</code> with pipes...</p>