* Mark Murray <[EMAIL PROTECTED]> [020625 02:26] wrote:
> 
> > I couldn't see a simple way around this, any clues?
> 
> How's this?
> 
> int handle;
> template = "/tmp/mumbleXXXXXXXX";
> char *cmd;
> handle = mkstemp(template); // template is modified
> asprintf(cmd, "prog > %s", template);
> system(cmd);
> close(handle); // bye-bye file

Kinda buggy. :)

int fd, status;
char *template = strdup("/tmp/mumbleXXXXXXXX");
if (template == NULL)
        /* ERROR */
fd = mkstemp(template);
if (fd == -1) {
        free(template);
        /* ERROR */
}
asprintf(cmd, "prog > %s", template);
status = system(cmd);
unlink(template);
free(cmd);
free(template);
close(fd);
/* if normal exit, return true if exit code was 0 (success) */
return (WIFEXITED(status) ? WEXITSTATUS(status) == EXIT_SUCCESS : 0);

-- 
-Alfred Perlstein [[EMAIL PROTECTED]]
'Instead of asking why a piece of software is using "1970s technology,"
 start asking why software is ignoring 30 years of accumulated wisdom.'
Tax deductible donations for FreeBSD: http://www.freebsdfoundation.org/

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to