Skip to content

Instantly share code, notes, and snippets.

@zdimension
Created March 31, 2023 22:17
Show Gist options
  • Save zdimension/e315b972b0f81e706db9a563e1d4acc0 to your computer and use it in GitHub Desktop.
Save zdimension/e315b972b0f81e706db9a563e1d4acc0 to your computer and use it in GitHub Desktop.
list function calls in a C file and look up in man
isatty (3) - test whether a file descriptor refers to a terminal
open (2) - open and possibly create a file
dup2 (2) - duplicate a file descriptor
close (2) - close a file descriptor
sigaction (2) - examine and change a signal action
execvp (3) - execute a file
cheatsheet (){ grep -oP '(\w+)(?=\()' $1 | xargs whatis -s 2,3 2>/dev/null; }
isatty(STDIN_FILENO) test whether a file descriptor refers to a terminal
open("/dev/null", O_WRONLY) open and possibly create a file
dup2(fd, STDIN_FILENO) duplicate a file descriptor
close(fd) close a file descriptor
sigaction(SIGHUP, &sa, NULL) examine and change a signal action
execvp(argv[1], &argv[1]) execute a file
cheatsheet (){ perl -ne'while(/(\w+)\((?:[^)(]+|(?R))*+\)/g){if(!$a{$1}){$n=$&;$a{$1}=1;`whatis -s2,3 $1 2>/dev/null`=~/-(.*)/&&printf"%-65s $1\n",$n}}' $1; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment