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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On a first shell I run the command tail with no argument.

On a second shell I kill the first tail using strace to monitor the system calls.

qdii@nomada ~ $ strace kill 1713
execve("/bin/kill", ["kill", "1713"], [/* 82 vars */]) = 0
brk(0)                                  = 0x2533000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f9dacfe8000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3

I didn’t know the brk command so I looked it up and found that it changes the end of the data segment of the process. Why would kill do that? especially setting the data segment to 0 seems to make little sense.

share|improve this question

The run-time library calls sbrk to read the current end of the data segment. sbrk is implemented on top of the brk syscall; as you can see, calling brk with an invalid address just returns the current value.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.