Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Does anyone have any useful mnemonics for remembering the order of function parameters or the return values of Unix system calls? I am suffering from "memory leaks".

share|improve this question
3  
Er. All of them? –  Michael Mrozek Mar 14 '11 at 13:58
    
This would be a perfect 'community wiki' question. –  Shawn J. Goff Mar 14 '11 at 14:23
5  
This is why man pages exist, so you don't have to remember them all. –  glenn jackman Mar 14 '11 at 15:40
    
@Michael: no, any of them. –  delete Mar 15 '11 at 2:48
    
@glenn: I would just love to be able to remember at least the most common ones so I didn't have to stop typing. –  delete Mar 15 '11 at 2:49
add comment

4 Answers

  1. Move cursor over syscall name
  2. Press 'K'

(Prerequisite: vi.)

share|improve this answer
    
-1 That is not an answer to my question. –  delete Mar 15 '11 at 2:49
    
+1 but it does work. –  Simon Richter Mar 15 '11 at 11:25
1  
I answered a higher-level question: "How do you remember the order of parameters to Unix system calls?" As you can see from the answers you've gotten, including the expected solution in the question can choke off good replies. –  Warren Young Mar 15 '11 at 20:12
    
"Look at the manual pages" is not a good reply to the question asked. The impression I get from that answer is that you assume that the person asking is ignorant of extremely basic Unix facilities. I am aware of several ways to look up the information, but I am specifically asking if anyone has mnemonics for system calls. –  delete Mar 17 '11 at 0:40
add comment

Most common syscalls - read(2) and write(2) takes 3 parameters: descriptor, buffer and length. Returns number of bytes actually read or written. close(2), obviously, takes one parameter - descriptor to close.

Most syscalls return -1 in case of error and sets errno.

Everything else I usually read in corresponding man page. Just don't forget the command: man 2 syscall_name

P.S.: do you have intro(2) ?

share|improve this answer
    
Thanks very much for at least trying to answer the question asked. –  delete Mar 17 '11 at 0:44
    
But it's worth noting that fread and fwrite are actually the opposite of read and write here. Which is why I was wondering about mnemonics. –  delete Mar 17 '11 at 0:57
    
fread and fwrite are library functions, not syscalls. They call read and write to do the job :) –  gelraen Mar 17 '11 at 8:14
add comment

This is a common problem for most developers. If you write code often you will eventually find some patterns that you can use as mnemonics, for example file descriptors are usually the first parameter. But there will always be annoying exceptions hard to memorize.

You are approaching the problem the wrong way. There is a good reason why so many sophisticated development tools exist. Instead of making your life harder, start using a specialized source code editor or an integrated development environment.

Some of the standard features (Auto-completion lists, realtime syntax checking, documentation tooltips) will eliminate your problem, taking away a big overhead for you. After all, that's what computers are for, doing the boring repetitive tasks, so you can focus on the interesting stuff.

share|improve this answer
    
This could have been a solution to the problem, if instead of linking to Wikipedia articles, you had put links to the "specialized source code editor" or "integrated development environment" which would tell me which parameters to use for which system calls. As it is this answer seems very patronizing. –  delete Mar 17 '11 at 0:43
    
Those links in the wikipedia are actually links to "source code editors" and "IDEs", if you look again you'll see that there is an extensive list of those tools in there. I like eclipse but you have to select one for your self. I'm sorry if I sound patronizing but you also seem you didn't put any effort to it. –  forcefsck Mar 17 '11 at 6:59
add comment

I use -h or --help or -?. Or sometimes man command.

share|improve this answer
1  
-h or --help -- that's something not about syscalls. –  imz -- Ivan Zakharyaschev Mar 16 '11 at 17:10
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.