2006-07-06 11:04:46 +00:00
|
|
|
// Berkeley Open Infrastructure for Network Computing
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2005 University of California
|
|
|
|
//
|
|
|
|
// This is free software; you can redistribute it and/or
|
|
|
|
// modify it under the terms of the GNU Lesser General Public
|
|
|
|
// License as published by the Free Software Foundation;
|
|
|
|
// either version 2.1 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// This software 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 Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// To view the GNU Lesser General Public License visit
|
|
|
|
// http://www.gnu.org/copyleft/lesser.html
|
|
|
|
// or write to the Free Software Foundation, Inc.,
|
|
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
2006-06-05 04:30:16 +00:00
|
|
|
// switcher.C
|
|
|
|
//
|
|
|
|
// When run as
|
2006-06-17 11:51:48 +00:00
|
|
|
// switcher Path X1 ... Xn
|
|
|
|
// runs program at Path with args X1. ... Xn
|
2006-06-05 04:30:16 +00:00
|
|
|
|
|
|
|
#include <unistd.h>
|
2006-06-17 11:51:48 +00:00
|
|
|
#include <stdio.h>
|
2006-07-01 05:32:02 +00:00
|
|
|
#include <cerrno>
|
2006-07-06 11:04:46 +00:00
|
|
|
#include <sys/param.h> // for MAXPATHLEN
|
2006-06-05 04:30:16 +00:00
|
|
|
|
2006-06-17 11:51:48 +00:00
|
|
|
int main(int argc, char** argv) {
|
|
|
|
|
2006-07-06 11:04:46 +00:00
|
|
|
#if 0 // For debugging only
|
|
|
|
char current_dir[MAXPATHLEN];
|
|
|
|
|
|
|
|
getcwd( current_dir, sizeof(current_dir));
|
|
|
|
fprintf(stderr, "current directory = %s\n", current_dir);
|
|
|
|
|
2006-06-17 11:51:48 +00:00
|
|
|
for (int i=0; i<argc; i++) {
|
|
|
|
fprintf(stderr, "switcher arg %d: %s\n", i, argv[i]);
|
|
|
|
}
|
|
|
|
fflush(stderr);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
execv(argv[1], argv+2);
|
2006-07-01 05:32:02 +00:00
|
|
|
|
|
|
|
// If we got here execv failed
|
|
|
|
fprintf(stderr, "Process creation (%s) failed: errno=%d\n", argv[1], errno);
|
|
|
|
|
2006-06-05 04:30:16 +00:00
|
|
|
}
|