title: Writing memory of the traced process.
body: <p>I am playing around with ptrace in linux. I am trying to write the memory  of the traced process using /proc/pid/mem interface. </p>
  
  <p>the function I ma using for accomplish this task is :</p>
  
  <pre><code>void write_proc(pid_t child, unsigned long int addr) {
  
    char mem_file_name[100];
    char buf[10]="hope";
    int mem_fd;
  
  
    memset( (void*)mem_file_name, 0, 100);
    memset( (void *)buf, 0, 10);
  
    sprintf(mem_file_name, "/proc/%d/mem", child);
    mem_fd = open(mem_file_name, O_RDONLY);
    lseek(mem_fd, addr , SEEK_SET);
  
    if (write(mem_fd, buf, 5) &lt; 0 )
      perror("Writing");
  
    return;
  
  }
  </code></pre>
  
  <p>But I always get the error : Writing: Bad file descriptor. </p>
  
  <p>Is it possible to write the traced process using this method? </p>