なんでもノート

t0m00m0tのノート。

CentOSでC関数を調べる

目的

Linuxのしくみを読んでいると、実験用のCサンプルプログラムが多数でてくる。C関数をサクッとLinuxで調べたい。

manコマンドでC関数を調べる

manのセクションの説明は次のとおり。3を指定すれば良い。

1   Executable programs or shell commands
2   System calls (functions provided by the kernel)
3   Library calls (functions within program libraries)
4   Special files (usually found in /dev)
5   File formats and conventions eg /etc/passwd
6   Games
7   Miscellaneous (including macro packages and conventions), e.g. man(7), groff(7)
8   System administration commands (usually only for root)
9   Kernel routines [Non standard]

早速やって見る。

セクション3を指定する場合

C関数のオンラインヘルプが表示される。 読み込むヘッダーも調査可能。

$ man 3 exit

NAME
       exit - cause normal process termination

SYNOPSIS
       #include <stdlib.h>

       void exit(int status);

DESCRIPTION
       The exit() function causes normal process termination and the value of status & 0377 is returned to the parent (see wait(2)).

セクション3を指定しない場合

同名のコマンドのオンラインヘルプが表示されてしまう。

$ man exit

NAME
       bash, :, ., [, alias, bg, bind, break, builtin, caller, cd, command, compgen, complete, compopt, continue, declare, dirs, disown, echo, enable, eval, exec, exit, export, false, fc, fg, getopts, hash, help, history, jobs, kill, let, local, logout, mapfile, popd, printf, pushd, pwd, read, readonly, return, set, shift, shopt, source, suspend, test, times, trap, true, type, typeset, ulimit, umask, unalias, unset, wait -  bash  built-in  commands, see bash(1)