This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ cat /etc/systemd/logind.conf | |
# This file is part of systemd. | |
# | |
# systemd 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. | |
# | |
# Entries in this file show the compile time defaults. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <unistd.h> | |
#include <sys/prctl.h> | |
int main() { | |
printf("origin: pid=%d, ppid=%d, pgid=%d\n", getpid(), getppid(), getpgid(getpid())); | |
printf("prctl %d\n", prctl(PR_SET_CHILD_SUBREAPER, 1, 0, 0, 0)); | |
pid_t pid = fork(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _GNU_SOURCE /* See feature_test_macros(7) */ | |
#include <sched.h> | |
#include <sys/syscall.h> /* Definition of SYS_* constants */ | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <errno.h> | |
#include <string.h> | |
#include <sys/wait.h> | |
#include <time.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run --rm --name pg -e POSTGRES_PASSWORD=123 -e POSTGRES_HOST_AUTH_METHOD=md5 postgres:latest | |
docker run --rm -e DATABASE_URL="postgres://postgres:[email protected]/postgres" -e POOL_MODE=session -p 5432:5432 --name pgb -it edoburu/pgbouncer /usr/bin/pgbouncer /etc/pgbouncer/pgbouncer.ini -v | |
psql postgres://postgres:123@pgb/ | |
# by default latest versions of PG use SASL+SCRAM-SHA-256 that is not support by the pgbouncer docker image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <errno.h> | |
#include <fcntl.h> | |
#include <stdio.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/mman.h> | |
#include <sys/stat.h> | |
#include <sys/types.h> | |
#include <unistd.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# to try this you'll need to edit in the name of your ruby binary and install bcc-tools | |
# bcc installation instructions are at https://github.com/iovisor/bcc/blob/master/INSTALL.md | |
from __future__ import print_function | |
from bcc import BPF | |
from time import sleep | |
import os | |
# load BPF program |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _MULTI_THREADED | |
#include <pthread.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
#include <errno.h> | |
#include <fcntl.h> | |
/* For safe condition variable usage, must use a boolean predicate and */ | |
/* a mutex with the condition. */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define _MULTI_THREADED | |
#include <pthread.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
/* For safe condition variable usage, must use a boolean predicate and */ | |
/* a mutex with the condition. */ | |
int workToDo = 0; | |
pthread_cond_t cond = PTHREAD_COND_INITIALIZER; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* For a Ruby program: | |
* | |
* $ cat prog.rb | |
* | |
* Thread.new { | |
* while true | |
* puts "2222222222222222222222222222222222222222222222222222222222222222222222" | |
* sleep 0.2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dl_iterate_phdr(scan_dynsym, NULL); | |
// | |
// better see the impl from musl: https://github.com/esmil/musl/blob/194f9cf93da8ae62491b7386edf481ea8565ae4e/src/ldso/dynlink.c#L1451 | |
#define UINTS_PER_WORD (__WORDSIZE / (CHAR_BIT * sizeof (unsigned int))) | |
static ElfW(Word) | |
gnu_hashtab_symbol_count(const unsigned int *const table) { | |
const unsigned int *const bucket = table + 4 + table[2] * (unsigned int)(UINTS_PER_WORD); | |
unsigned int b = table[0]; |