-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetaffin.c
63 lines (50 loc) · 1.31 KB
/
setaffin.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// setaffin.c -- a wrapper program to set CPU affinity.
#include <windows.h>
int usage(void);
int main(int argc, char* argv[])
{
HANDLE Process = GetCurrentProcess();
STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcInfo;
char CmdLine[1024] = "";
int arg;
if (argc == 1) {
usage();
return 0;
}
// There must be a nicer way of getting the command-line
// all into a nice string, but I dont' know it. Wish it
// were sane to write this in Perl instead.
for (arg = 1; arg < argc; arg++) {
strcat (CmdLine, argv[arg]);
strcat (CmdLine, " ");
}
printf("\nGetting Startup Info structure.\n");
GetStartupInfo(&StartupInfo);
printf ("Setting affinity mask to CPU 0...");
if (SetProcessAffinityMask( Process, 1)) {
printf(" succees.\n");
}
else {
printf(" FAILED.\n");
printf("Please submit a detailed bug report.\n\n");
return 0;
}
printf ("Now Launching %s...", CmdLine);
if (CreateProcess( NULL, CmdLine, NULL, NULL, 0, 0,
NULL, NULL, &StartupInfo, &ProcInfo)) {
printf(" success.\n");
return 1;
}
else {
printf(" FAILED.\n");
printf("Check your command-line for errors.\n\n");
printf("If you believe it should have worked, please submit a detailed bug report.\n");
return 0;
}
}
int usage (void)
{
printf ("\nUsage: setaffin <program> <arguments>\n\n");
return 0;
}