Skip to content

Instantly share code, notes, and snippets.

/* https://github.com/shichao-an/linux-2.6.34.7/blob/master/kernel/sched.c#L89
*/
/*
* Convert user-nice values [ -20 ... 0 ... 19 ]
* to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
* and back.
*/
#define NICE_TO_PRIO(nice) (MAX_RT_PRIO + (nice) + 20)
#define PRIO_TO_NICE(prio) ((prio) - MAX_RT_PRIO - 20)
#define TASK_NICE(p) PRIO_TO_NICE((p)->static_prio)
#include <signal.h>
void (*signal(int signo, void (*func)(int)))(int);
/* Returns: previous disposition of signal (see following) if OK, SIG_ERR on error */
#include <termios.h>
pid_t tcgetsid(int fd);
/* Returns: session leader’s process group ID if OK, −1 on error */
#include <termios.h>
pid_t tcgetsid(int fd);
/* Returns: session leader’s process group ID if OK, −1 on error */
#include <unistd.h>
pid_t tcgetpgrp(int fd);
/* Returns: process group ID of foreground process group if OK, −1 on error */
int tcsetpgrp(int fd, pid_t pgrpid);
/* Returns: 0 if OK, −1 on error */
#include <unistd.h>
pid_t getsid(pid_t pid);
/* Returns: session leader’s process group ID if OK, −1 on error */
#include <unistd.h>
pid_t setsid(void);
/* Returns: process group ID if OK, −1 on error */
#include <unistd.h>
int setpgid(pid_t pid, pid_t pgid);
/* Returns: 0 if OK, −1 on error */
#include <unistd.h>
pid_t getpgrp(void);
/* Returns: process group ID of calling process */
pid_t getpgid(pid_t pid);
/* Returns: process group ID if OK, −1 on error */
#include <sys/times.h>
clock_t times(struct tms *buf);
/* Returns: elapsed wall clock time in clock ticks if OK, −1 on error */