From Pickwiki
Jump to navigationJump to search



by Dave Church

This C program changes the process group id for a Universe cron job.

Clifton Oliver: [The process group id] is used to determine the id of the printer memory segment for the process. If you have two UV processes with the same pgid, they end up sharing the memory segment. This is where your MFILE structures are stored (rotating file pool), among other things. Pointers get mixed up, and you end up getting some file's data written into a completely different file, usually corrupting the group or even the file header, depending on how angry the computer gods are that day.

/* This c routine can be used to start universe processes 
   in cron or at.  Normally only one process can run at a 
   time because they use the same printer memory segment. 
   simply replace the 'uv' command with 'uvcron' for example: 
   uvcron 'BATCH-REPORT1' > dave.mail */

#define UCB 0  /* set to 0 for System V or 1 for Berkeley */

main(argc, argv, envp)
int argc;
char *argv[], *envp[];
#if UCB 
   (void)setpgrp(0, getpid());

   (void)execve("/u1/uv/bin/uv", argv, envp);

   /* We should never come back here */
   printf("exec failed\n");

Note that a common workaround is to use PHANTOM commands in cron, e.g.:

0 1 * * * /u1/uv/bin/uv "PHANTOM BATCH-REPORT1"

Perry Taylor: One disadvantage to using PHANTOM are the challenges required to retrieve the output from the program. For example, suppose you needed to get some piece of data from Universe to use in a shell script, say the email address to which to mail a report. The BASIC program MAILTO.LOOKUP does the lookup and CRT's the email address. Using uvcron you could do the following...

mail_to=$(cd $your_uv_account_dir && uvcron 'RUN BP MAILTO.LOOKUP')

This would be much more difficult to retrieve if MAILTO.LOOKUP were run as a PHANTOM.