Hello

My IRC chatbot – SeeBorg.

My dance music podcast.

My music.

Some bits

Undocumented or rare but very useful.

  • close(2) with enabled SO_LINGER results in block even if socket is nonblocking, blocks for 'linger_timeout' at most.
  • To fix iosnoop dynamic variable drops, edit it and add this:
    #pragma D option dynvarsize=16m

    Tweak this value up until you stop getting dynamic variable drops.

  • To avoid creating temporary files:
    diff -u <(sort /etc/passwd) <(shuf /etc/passwd | sort)
  • To disable mobile time machine:
    sudo tmutil disablelocal
  • To have a meaningful stack trace with optimized code:
    -fno-optimize-sibling-calls
  • To flush caches on Linux (I don't need to do that very often nowadays):
    sudo sh -c "sync; echo 3 > /proc/sys/vm/drop_caches"

    OSX:

    purge
  • Disable OSX UBC for a given file globally:
    fcntl(fd, F_GLOBAL_NOCACHE, 1);

Sendfile overview

Mach Sendfile

int sendfile(int fd, int s, off_t offset, off_t *len, struct sf_hdtr* hdtr, int flags);

  • Offset can't fall beyond EOF
  • len can't be NULL
  • on return, len is number of bytes successfully sent
  • returns EAGAIN on non-blocking fd
  • on EINTR, len of 0 does not mean everything was copied
  • len 0 → till EOF
  • FD must point to regular file
  • s must be sock_stream socket

FreeBSD sendfile()

int sendfile(int fd, int s, off_t offset, size_t nbytes, struct sf_hdtr *hdtr, off_t *sbytes, int flags);

  • offset can't fall beyond EOF
  • nbytes 0 → till eof
  • sbytes – total bytes sent
  • flags sf_nodiskio – no blocking or return EBUSY
  • fd must be file descriptor
  • s must be sock_stream descriptor
  • on EINTR, some data might be already sent

Sun Solaris sendfile()

ssize_t sendfile(int out, int in, off_t *off, size_t len);

  • in must be regular file
  • out must be sock_stream socket
  • off is pointer to offset
  • on return, off points to byte following last byte that was read
  • does not modify in_fd offset
  • does modify out_fd offset
  • on EINTR, no data was transferred

Linux sendfile()

ssize_t sendfile(int out, int in, off_t *offset, size_t count);

  • If offset is set to NULL, update in_fd's offset
  • else write to offset
  • in_fd must support mmap()
  • in_fd can't be socket
  • count can't be zero
  • user should fall back to read()/write() if sendfile() fails with EINVAL or ENOSYS
  • returns EAGAIN on non-blocking FD


Links

My Twitter

(1 day, 6 hours ago) Jonathan Coulton Speaks On MegaUpload, SOPA & More http://t.co/zJqACRC0
(1 day, 6 hours ago) Warner Music Orders YouTube Takedown Of Slow Motion Crochet Video With No Music http://t.co/wVpmF1Lz
(1 day, 6 hours ago) What Can the Experts Teach You about Recording Vocals? http://t.co/teIMnFl1
(1 day, 14 hours ago) LA porn stars told to use condoms — http://t.co/iJXivqph
(1 day, 16 hours ago) Порноактеров Лос-Анджелеса обязали надевать презервативы http://t.co/ro0M0MLg

 
Made on a Mac