News for hackers. Stuff that matters.
Re:The Magic of strace by rosser on Friday January 31, 2014 @03:17AM (#7155861)
Small, somewhat nit-picky critique: the man pages for system calls are in section 2. If you want to see the docs for the "read()" syscall, and not the bash builtin "read", saying "man read" w̶o̶n̶'̶t̶ may not (see follow-up) do what you expect. Instead, you should say

  man 2 read
This should probably be mentioned somewhere.

Otherwise, great writeup. Thanks for sharing!

(edited)

Re:The Magic of strace by danielweber on Friday January 31, 2014 @08:21AM (#7156490)
Different Unix systems take different syntax for specifying the section. Long ago I learned to say "man -a read" and just get _all_ the "read" pages, scanning for the ones I want (and sometimes learning about things I didn't know were there).
Re:The Magic of strace by holyjaw on Friday January 31, 2014 @04:46PM (#7159382)
I'm going to hijack this comment to ask a question that I haven't been able to google:

What is the number after the command called? For example, when I look up 'man sed', I find a manpage for 'sed(1)'[0]. When I look up 'man kill', I find manpages for 'kill(1)' and 'kill(2)'[2].

Can somebody tell me what that number is called so I can look it up? Thanks..

0: https://developer.apple.com/library/mac/documentation/Darwin... 1: https://developer.apple.com/library/mac/documentation/Darwin... 2: http://man7.org/linux/man-pages/man2/kill.2.html

Re:The Magic of strace by rosser on Friday January 31, 2014 @05:18PM (#7159552)
That's the "section" I'm talking about. "sed(1)" means that the man page for that sed is in section 1. "kill(1)" versus "kill(2)" likewise: the former is the command; the latter is the syscall. To distinguish between them, you need to tell man(1) which section to look in for the desired context.
Re:The Magic of strace by arxanas on Friday January 31, 2014 @04:58PM (#7159442)
That number refers to the section of the man pages that the command is in. See http://en.wikipedia.org/wiki/Man_page#Manual_sections for an example list; however, it seems the list is not the same between systems.
Re:The Magic of strace by JoshTriplett on Friday January 31, 2014 @03:43AM (#7155906)
There's a manpage bash-builtins in section 7, but I've never seen a system that had manpages for the individual builtins, let alone having them in section 1. "man read" on every system I've used opens the read manpage in section 2.
Re:The Magic of strace by rosser on Friday January 31, 2014 @03:46AM (#7155913)
My local CentOS 6.2 VM has bash-builtins in section 1, which is where "man read" takes me. Same with a RHEL 6.4 machine in the colo.

This might be a distro-specific thing.

Re:The Magic of strace by _delirium on Friday January 31, 2014 @07:40AM (#7156367)
Same with OSX: "man read" opens the builtin(1) manpage. However on Debian 7.3, it opens read(2).
Re:The Magic of strace by noselasd on Saturday February 01, 2014 @09:56PM (#7164596)
You can configure the priority of the sections in /etc/man.conf or similar.
Re:The Magic of strace by justincormack on Friday January 31, 2014 @03:45AM (#7155912)
Some syscalls share names with commands in section 1 though.
Re:The Magic of strace by GFK_of_xmaspast on Friday January 31, 2014 @12:07PM (#7157662)
I can't remember a unix system for at least the last decade that hasn't given me the section 1 bash "read" instead of the section 2 system "read" on a "man read".
Re:The Magic of strace by coryfklein on Friday January 31, 2014 @12:23PM (#7157782)
I've been on Ubuntu for several years, and I see the same as JoshTriplett. Must be platform dependent.
Re:The Magic of strace by JasuM on Friday January 31, 2014 @08:40AM (#7156567)
At least on my Mac, it opens the page for BUILTIN(1).
Re:The Magic of strace by Hello71 on Friday January 31, 2014 @07:25AM (#7156318)
read is also documented by POSIX, and those man pages are often installed in section 1p.
Re:The Magic of strace by wglb on Friday January 31, 2014 @09:18AM (#7156691)
This is why the documentation for COHERENT was changed from "man" pages to what we called a Lexicon, removing the concept of sections. Each entry would have the description of the type of the entry, such as system call, shell command, and so on. Steve Ness has made this available online at http://www.nesssoftware.com/home/mwc/manual.php
Re:The Magic of strace by CUViper on Friday January 31, 2014 @02:39PM (#7158709)
You can change the section search order with the SECTION directive in /etc/man_db.conf, or you can override that global setting with the MANSECT environment variable. I just learned this from "man man". :) I'm personally tempted to put "2 3" ahead of the rest, because most of the time I'm just trying to refresh my memory on function parameters.