16.05.2015 Views

Working with the Unix OS

Working with the Unix OS

Working with the Unix OS

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Interprocess Communication<br />

11. INTERPROCESS COMMUNICATION<br />

What are <strong>the</strong> limitations of <strong>the</strong> following?<br />

- Pipes<br />

- Named pipes<br />

- Signals via kill<br />

System V IPCs:<br />

- messages<br />

- shared memory<br />

- semaphores<br />

BSD sockets<br />

Process Training<br />

A debugger process, such as sdb, spawns a process to be traced and controls its execution <strong>with</strong> ptrace system call.<br />

if ((pid = fork()) == 0)<br />

{<br />

/* child -traced process */<br />

ptrace(0, 0, 0, 0);<br />

exec("name of traced process here");<br />

}<br />

for (;;) /* debugger process continues here */<br />

{<br />

wait((int *) 0);<br />

read(input for tracing instructions)<br />

ptrace(cmd, pid, addr, data);<br />

if (quiting trace)<br />

break;<br />

}<br />

! ptrace<br />

cmd = reading data, writing data, resuming execution<br />

pid = process ID of traced process<br />

addr = virtual address to be read/written in child<br />

data = integer value to be written<br />

/* -------------------------------------- */<br />

/* trace */<br />

int data[32];<br />

main()<br />

{<br />

int i;<br />

for (i=0; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!