[cups] cupsdStartProcess question
Michael Sweet
msweet at apple.com
Tue May 10 07:32:53 PDT 2016
Dmitry,
> On May 9, 2016, at 1:16 AM, Dmitry Voronin <carriingfate92 at yandex.ru> wrote:
>
> Hello,
>
> For my reasons in CUPS I need execute external program and save output into file.
>
> I determine, that function cupsdStartProcess is more suitable, that system or exec* function.
cupsdStartProcess isn't intended as a general API for user programs, it is an internal function used by the scheduler (cupsd).
posix_spawn is a better alternative (and a portable API) that can handle redirecting stdout to a file.
>
> So, I have following code:
>
> outfd = open('/tmp/exec", O_WRONLY);
>
> status = cupsdStartProcess(command, argv, envp,
> -1 /* intfd */,
> outfd /* opened early */,
> -1 /* errfd */,
> -1 /* backfd */,
> -1 /* sidefd */,
> 1 /* execute as root */,
> NULL /* profile */,
> NULL /*job */,
> &pid /* running pid */);
>
> if (!status)
> close(outfd);
> else
> {
> close(outfd);
> unlink("/tmp/exec");
> }
>
> When those code is executed, I expect, that in file with fd outfd it was written output of my command. But those file is empty. In /var/spool/cups/tmp/ (I use Debian)
> CUPS create a random file with neede for me output.
>
> What am I doing wrong?
>
> Thank you.
> --
> Best regards, Dmitry Voronin
> _______________________________________________
> cups mailing list
> cups at cups.org
> https://www.cups.org/mailman/listinfo/cups
_________________________________________________________
Michael Sweet, Senior Printing System Engineer
More information about the cups
mailing list