tools/power/x86/intel-speed-select/isst-daemon.c
Source file repositories/reference/linux-study-clean/tools/power/x86/intel-speed-select/isst-daemon.c
File Facts
- System
- Linux kernel
- Corpus path
tools/power/x86/intel-speed-select/isst-daemon.c- Extension
.c- Size
- 5700 bytes
- Lines
- 257
- Domain
- Support Tooling And Documentation
- Bucket
- tools
- Inferred role
- Support Tooling And Documentation: implementation source
- Status
- source implementation candidate
Why This File Exists
Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
stdio.hstdlib.hstdarg.hstring.hunistd.hfcntl.hsys/file.hsys/types.hsys/stat.herrno.hgetopt.hsignal.htime.hisst.h
Detected Declarations
function init_levelsfunction process_level_changefunction _poll_for_config_changefunction poll_for_config_changefunction signal_handlerfunction daemonizefunction isst_daemon
Annotated Snippet
if (CPU_ISSET_S(i, ctdp_level.core_cpumask_size, ctdp_level.core_cpumask)) {
fprintf(stderr, "online cpu %d\n", i);
set_cpu_online_offline(i, 1);
} else {
fprintf(stderr, "offline cpu %d\n", i);
set_cpu_online_offline(i, 0);
}
}
}
free_mask:
free_cpu_set(ctdp_level.core_cpumask);
}
static void _poll_for_config_change(struct isst_id *id, void *arg1, void *arg2,
void *arg3, void *arg4)
{
process_level_change(id);
}
static void poll_for_config_change(void)
{
for_each_online_power_domain_in_set(_poll_for_config_change, NULL, NULL,
NULL, NULL);
}
static int done = 0;
static int pid_file_handle;
static void signal_handler(int sig)
{
switch (sig) {
case SIGINT:
case SIGTERM:
done = 1;
hfi_exit();
exit(0);
break;
default:
break;
}
}
static void daemonize(char *rundir, char *pidfile)
{
int pid, sid, i;
char str[10];
struct sigaction sig_actions;
sigset_t sig_set;
int ret;
if (getppid() == 1)
return;
sigemptyset(&sig_set);
sigaddset(&sig_set, SIGCHLD);
sigaddset(&sig_set, SIGTSTP);
sigaddset(&sig_set, SIGTTOU);
sigaddset(&sig_set, SIGTTIN);
sigprocmask(SIG_BLOCK, &sig_set, NULL);
sig_actions.sa_handler = signal_handler;
sigemptyset(&sig_actions.sa_mask);
sig_actions.sa_flags = 0;
sigaction(SIGHUP, &sig_actions, NULL);
sigaction(SIGTERM, &sig_actions, NULL);
sigaction(SIGINT, &sig_actions, NULL);
pid = fork();
if (pid < 0) {
/* Could not fork */
exit(EXIT_FAILURE);
}
if (pid > 0)
exit(EXIT_SUCCESS);
umask(027);
sid = setsid();
if (sid < 0)
exit(EXIT_FAILURE);
/* close all descriptors */
for (i = getdtablesize(); i >= 0; --i)
close(i);
i = open("/dev/null", O_RDWR);
if (i < 0)
exit(EXIT_FAILURE);
Annotation
- Immediate include surface: `stdio.h`, `stdlib.h`, `stdarg.h`, `string.h`, `unistd.h`, `fcntl.h`, `sys/file.h`, `sys/types.h`.
- Detected declarations: `function init_levels`, `function process_level_change`, `function _poll_for_config_change`, `function poll_for_config_change`, `function signal_handler`, `function daemonize`, `function isst_daemon`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.