I've done something similiar.
However, I think you can simplify it a bit.
Allow your mud to parse a command line parameter.
Then call the function based on that, (do no load the world files at all)
and exit.
Run each night with cron or something.
if (argc>1) {
if (argv[2] && !strcmp(argv[2], "-molest")) {
molest_all_players();
}
if (argv[2] && !strcmp(argv[2], "-delete")) {
delete_players();
}
if (argv[2] && !strcmp(argv[2], "-clanaudit")) {
clan_audit();
}
if (argv[2] && !strcmp(argv[2], "-adjaudit")) {
adjective_audit();
}
merc_down=TRUE;
}
This is just a generic idea.
To use fork():
a = fork();
if (!a){
background_process();
exit();
}
if (a==-1){
/* fork failure */
}
If you use fork, you need to get into signals and deal with the ones child
processes use.
> -----Original Message-----
> From: Dale Kingston [mailto:[EMAIL PROTECTED]
> Sent: Saturday, August 02, 2003 9:45 PM
> To: [email protected]
> Subject: Fork()
>
>
> Does anyone know where I could read up on how to use fork()?
> Would like the mud to do something on the side, but it's
> going to take a second or two to process it.
>
> Basically I've made a pfile cleaner to go through and clean
> up the pfiles remove old ones what not. And I have it do a
> backup to when it does this. But it causes the mud to halt
> for a second while it does all this. So I've heard/seen a
> little bit on fork. But idk really how to use it. This
> cleaner is just one function so would I just like:
>
> if (fork())
> {
> clean_pfiles();
> exit(0);
> }
>
> Or how would I use fork to do that. I don't need anything
> from the process information wise. I would just need it to
> run this one function and the close the process.
>
> So if anyone knows somewhere, where I could read up on it. Or
> maybe an explaininaion on how to do this would be very appreciated.
>
>
> --
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom
>