This allows to distinguish the afs process from the main server
process by looking at the ps output. Although there are less hacky
ways to achieve this (prctl(PR_SET_NAME, ...), setproctitle()), the
argv approach has the advantage of working on all supported operating
systems except FreeBSD. We have been doing the argv mangling for a
long time now in the command handlers and it has never caused any
problems, so it should be safe.
-static int init_afs(void)
+static int init_afs(int argc, char **argv)
{
int ret, afs_server_socket[2];
pid_t afs_pid;
{
int ret, afs_server_socket[2];
pid_t afs_pid;
if (afs_pid < 0)
exit(EXIT_FAILURE);
if (afs_pid == 0) { /* child (afs) */
if (afs_pid < 0)
exit(EXIT_FAILURE);
if (afs_pid == 0) { /* child (afs) */
+ int i;
+ for (i = argc - 1; i >= 0; i--)
+ memset(argv[i], 0, strlen(argv[i]));
+ sprintf(argv[0], "para_server (afs)");
close(afs_server_socket[0]);
afs_init(afs_socket_cookie, afs_server_socket[1]);
}
close(afs_server_socket[0]);
afs_init(afs_socket_cookie, afs_server_socket[1]);
}
*/
para_sigaction(SIGCHLD, tmp_sigchld_handler);
PARA_NOTICE_LOG("initializing the audio file selector\n");
*/
para_sigaction(SIGCHLD, tmp_sigchld_handler);
PARA_NOTICE_LOG("initializing the audio file selector\n");
- afs_socket = init_afs();
+ afs_socket = init_afs(argc, argv);
init_signal_task();
PARA_NOTICE_LOG("initializing virtual streaming system\n");
init_vss_task(afs_socket);
init_signal_task();
PARA_NOTICE_LOG("initializing virtual streaming system\n");
init_vss_task(afs_socket);