Archive for the 'geek' Category
broken pipe

if you try to send() (or sendto()) on a unix/linux socket that has been closed from the remote side, your application will get a SIGPIPE. if you do not explicitly handle a SIGPIPE, your application will exit, and you may see ‘Broken Pipe’ printed to STDERR.

You can add code to handle (read: ignore) a SIGPIPE as follows:


if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
perror("sigpipe error");
exit(0);
}

Now, when you send() (or sendto()) on a socket that has been remotely closed you should get a -1 return, with errno set to 32 (EPIPE).

no core generated

Your /etc/profile might have a line like this:

# No core files by default
ulimit -S -c 0 > /dev/null 2>&1

‘-c 0′ means that core file are to be of size 0. that is, there will be no core files.

This can be fixed by typing:

$ulimit -c unlimited

Note that this fix only works for the terminal that line is typed in.

removing a file descriptor from a poll set

If the fd member of a struct pollfd in the array passed to poll() is set to −1, it will be ignored.

unlimited bash history