site_archiver@lists.apple.com Delivered-To: darwin-dev@lists.apple.com Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=lIaw6vG3tGiUnZjko8NIDbjquDA09h/rXjpgxxz7zW9xiHIfF8ghQhe6T+RLac8TARNnXJnibyMhIHGlsw0LRqTb62/aRQylrzGzvW2YJ57iqRYlHTlDQgQYPFrBPGE8D8O9uP9pAQsB+PauNLAsQqQ9W3+7LQengNqwNTLlCKU= So I was very sad to learn that popen with r+ doesn't work on jaguar and panther, at least without the latest OS Updates. Is there any other API that I can use to accomplish launching a process and then reading from its stdout and writing to its stdin that works on both Jaguar and Panther using non NSTask stuff. I tried looking at popen's source and doing the pipes and forks like it does it but fdopen keeps returning EINVAL (22) not liking the "r+" mode I send it. Here is my ldpopen method: i call it using ldpopen(command, "r+"); static int pid = -1; static FILE * ldpopen(const char *command, const char *type) { char *argv[4]; int pdes[2]; FILE *iop; if (pipe(pdes) < 0) return (NULL); argv[0] = "sh"; argv[1] = "-c"; argv[2] = (char *)command; argv[3] = NULL; switch (pid = vfork()) { case -1: close(pdes[0]); close(pdes[1]); return NULL; case 0: close(pdes[0]); if (pdes[1] != STDOUT_FILENO) { (void)dup2(pdes[1], STDOUT_FILENO); (void)close(pdes[1]); errno = 0; int prob = dup2(STDOUT_FILENO, STDIN_FILENO); int y = errno; y = prob; } else if (pdes[1] != STDIN_FILENO) { (void)dup2(pdes[1], STDIN_FILENO); } execv(_PATH_BSHELL, argv); exit(127); } if (*type == 'r') { iop = fdopen(pdes[0], type); // this returns null with errno being 22 (void)close(pdes[1]); } else { iop = fdopen(pdes[1], type); (void)close(pdes[0]); } return iop; } Any help would be greatly appreciated, thanks. Matt _______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (Darwin-dev@lists.apple.com) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/site_archiver%40lists.appl... This email sent to site_archiver@lists.apple.com
participants (1)
-
matt jaffa