@@ -59,7 +59,7 @@ void check_requirements()
59
59
60
60
/**
61
61
* Check for root
62
- */
62
+ */
63
63
64
64
uid_t uid = getuid (), euid = geteuid ();
65
65
@@ -71,42 +71,28 @@ void check_requirements()
71
71
72
72
/**
73
73
* Check for coretemp and applesmc modules
74
- * Credits: -http://stackoverflow.com/questions/12978794
75
74
*/
76
- FILE * fd = popen ("lsmod | grep coretemp" , "r" );
77
- char buf [16 ];
78
-
79
- if (!(fread (buf , 1 , sizeof (buf ), fd ) > 0 )) {
80
- DIR * dir = opendir (CORETEMP_PATH );
81
-
82
- if (ENOENT == errno ) {
83
- syslog (LOG_ERR , "%s needs coretemp support. Please either load it or build it into the kernel. Exiting." , PROGRAM_NAME );
84
- printf ("%s needs coretemp module.\nPlease either load it or build it into the kernel. Exiting.\n" , PROGRAM_NAME );
85
- exit (EXIT_FAILURE );
86
- }
87
-
88
- closedir (dir );
75
+ DIR * dir = opendir (CORETEMP_PATH );
89
76
77
+ if (ENOENT == errno ) {
78
+ syslog (LOG_ERR , "%s needs coretemp support. Please either load it or build it into the kernel. Exiting." , PROGRAM_NAME );
79
+ printf ("%s needs coretemp module.\nPlease either load it or build it into the kernel. Exiting.\n" , PROGRAM_NAME );
80
+ exit (EXIT_FAILURE );
90
81
}
91
82
92
- pclose ( fd );
83
+ closedir ( dir );
93
84
94
- fd = popen ("lsmod | grep applesmc" , "r" );
95
85
96
- if (!(fread (buf , 1 , sizeof (buf ), fd ) > 0 )) {
97
- DIR * dir = opendir (APPLESMC_PATH );
98
-
99
- if (ENOENT == errno ) {
100
- syslog (LOG_ERR , "%s needs applesmc support. Please either load it or build it into the kernel. Exiting." , PROGRAM_NAME );
101
- printf ("%s needs applesmc module.\nPlease either load it or build it into the kernel. Exiting.\n" , PROGRAM_NAME );
102
- exit (EXIT_FAILURE );
103
- }
104
-
105
- closedir (dir );
86
+ dir = opendir (APPLESMC_PATH );
106
87
88
+ if (ENOENT == errno ) {
89
+ syslog (LOG_ERR , "%s needs applesmc support. Please either load it or build it into the kernel. Exiting." , PROGRAM_NAME );
90
+ printf ("%s needs applesmc module.\nPlease either load it or build it into the kernel. Exiting.\n" , PROGRAM_NAME );
91
+ exit (EXIT_FAILURE );
107
92
}
108
93
109
- pclose (fd );
94
+ closedir (dir );
95
+
110
96
111
97
}
112
98
0 commit comments