<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def pid(self, pidnum):
 """Set the pid for a running process."""

        try:

            with open(self.pidfile, "w+") as pidfile:

                pidfile.write("{0}\n".format(pidnum))

        except IOError:

            LOG.exception("Failed to write pidfile {0}).".format(self.pidfile))
            sys.exit(exit.PIDFILE_INACCESSIBLE)