⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 Path MPICH-V for MPICH the MPI Implementation
💻 C
字号:
/*  MPICH-V2  Copyright (C) 2002, 2003 Groupe Cluster et Grid, LRI, Universite de Paris Sud  This file is part of MPICH-V2.  MPICH-V2 is free software; you can redistribute it and/or modify  it under the terms of the GNU General Public License as published by  the Free Software Foundation; either version 2 of the License, or  (at your option) any later version.  MPICH-V2 is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License for more details.  You should have received a copy of the GNU General Public License  along with MPICH-V2; if not, write to the Free Software  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA  $Id: main.c,v 1.1.1.1 2004/01/30 15:49:38 lemarini Exp $*/#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <sys/socket.h>#include <netinet/in.h>#include <unistd.h>#include <signal.h>#define MULTIPLEXOR      "multiplex"#define MULTIPLEXOR_PATH "./multiplex"#define FILEFEEDER       "filefeeder"#define FILEFEEDER_PATH "./filefeeder"#include "glogd.h"#include "gta.h"#include "gld.h"static int pid = -1;void on_quit(int s){  if(pid > 0)    kill(pid, SIGTERM);  pid = -1;  exit(0);}int main(int argc, char *argv[]){  GtkWidget *logd;  int sv[2];  int isport = 1;  char *p;  gtk_init(&argc, &argv);  if(argc < 2)    {      fprintf(stderr, "usage : %s <port>|<file>\n", argv[0]);      return -1;    }  if(socketpair(AF_UNIX, SOCK_STREAM, 0, sv) < 0)    {      perror("socketpair");      return -1;    }  signal(SIGINT, on_quit);  signal(SIGTERM, on_quit);  signal(SIGQUIT, on_quit);  for(p = argv[1]; *p; p++)    if( (*p > '9') || (*p < '0') )      {	isport = 0;	break;      }  switch( (pid = fork()) )    {    case -1:      perror("fork");      return -1;    case 0:      close(0);      close(1);      dup(sv[1]);      dup(sv[1]);      if(isport)	{	  execl( MULTIPLEXOR_PATH, MULTIPLEXOR, argv[1], NULL);	  perror("execl");	  fprintf(stderr, "could not execute " MULTIPLEXOR " in " MULTIPLEXOR_PATH " with arg %s\n", argv[1]);	  _exit(0);	}      else	{	  execl( FILEFEEDER_PATH, FILEFEEDER, argv[1], NULL);	  perror("execl");	  fprintf(stderr, "could not execute " FILEFEEDER " in " FILEFEEDER_PATH " with arg %s\n", argv[1]);	  _exit(0);	}    default:      break;    }  logd = glogd_new(sv[0]);  gtk_widget_show(logd);  gtk_signal_connect(GTK_OBJECT( logd ), "delete_event",		     GTK_SIGNAL_FUNC(gtk_main_quit), NULL);    glogd_register_logger( GLOGD(logd), "New VUE meter", 			 GLOGD_NEW_LOGGER_FUNC(gta_new));  glogd_register_logger( GLOGD(logd), "New message visualizer",			 GLOGD_NEW_LOGGER_FUNC(gld_new));  gtk_main();  if(pid > 0)    kill(pid, SIGTERM);  pid = -1;  return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -