pi = (struct procinfo *) xmalloc (sizeof (struct procinfo));
if ((pi = create_procinfo (PIDGET (ptid), 0)) == NULL) perror ("procfs: out of memory in 'attach'");
do_attach (pid)     int pid;{  struct procinfo *pi;  pi = (struct procinfo *) xmalloc (sizeof (struct procinfo));  if (!open_proc_file (pid, pi, O_RDWR))    {      free (pi);      perror_with_name (pi->pathname);      /* NOTREACHED */    }    pid = pi -> pid;  /* Add new process to process info list */  pi->next = procinfo_list;  procinfo_list = pi;  add_fd (pi);			/* Add to list for poll/select */  /*  Get current status of process and if it is not already stopped,      then stop it.  Remember whether or not it was stopped when we first      examined it. */    if (ioctl (pi->fd, PIOCSTATUS, &pi->prstatus) < 0)    {      print_sys_errmsg (pi->pathname, errno);      close_proc_file (pi);      error ("PIOCSTATUS failed");    }  if (pi->prstatus.pr_flags & (PR_STOPPED | PR_ISTOP))    {      pi->was_stopped = 1;    }  else    {      pi->was_stopped = 0;      if (1 || query ("Process is currently running, stop it? "))	{	  /* Make it run again when we close it.  */	  modify_run_on_last_close_flag (pi->fd, 1);	  if (ioctl (pi->fd, PIOCSTOP, &pi->prstatus) < 0)	    {	      print_sys_errmsg (pi->pathname, errno);	      close_proc_file (pi);	      error ("PIOCSTOP failed");	    }	  pi->nopass_next_sigstop = 1;	}      else	{	  printf_unfiltered ("Ok, gdb will wait for %s to stop.\n", target_pid_to_str (pid));	}    }  /*  Remember some things about the inferior that we will, or might, change      so that we can restore them when we detach. */    ioctl (pi->fd, PIOCGTRACE, &pi->saved_trace);  ioctl (pi->fd, PIOCGHOLD, &pi->saved_sighold);  ioctl (pi->fd, PIOCGFAULT, &pi->saved_fltset);  ioctl (pi->fd, PIOCGENTRY, &pi->saved_entryset);  ioctl (pi->fd, PIOCGEXIT, &pi->saved_exitset);    /* Set up trace and fault sets, as gdb expects them. */    memset (&pi->prrun, 0, sizeof (pi->prrun));  prfillset (&pi->prrun.pr_trace);  procfs_notice_signals (pid);  prfillset (&pi->prrun.pr_fault);  prdelset (&pi->prrun.pr_fault, FLTPAGE);#ifdef PROCFS_DONT_TRACE_FAULTS  premptyset (&pi->prrun.pr_fault);#endif  if (ioctl (pi->fd, PIOCSFAULT, &pi->prrun.pr_fault))    {      print_sys_errmsg ("PIOCSFAULT failed", errno);    }  if (ioctl (pi->fd, PIOCSTRACE, &pi->prrun.pr_trace))    {      print_sys_errmsg ("PIOCSTRACE failed", errno);    }  attach_flag = 1;  return (pid);}