<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def register(self, fd, eventmask=None):
 """ Register a new descriptor :param fd: The descriptor to register. :param eventmask: Bit-mask of events that will be monitored. By default EPOLLIN, EPOLLOUT and EPOLLPRI are used. Note that EPOLLHUP is implicit and doesn't need to be provided. :raises ValueError: If :meth:`closed()` is True :raises OSError: If the underlying ``epoll_ctl(2)`` fails. The error message matches those found in the manual page. """

        if self._epfd < 0:
            _err_closed()
        if eventmask is None:
            eventmask = EPOLLIN | EPOLLOUT | EPOLLPRI
        ev = epoll_event()
        ev.events = eventmask
        ev.data.fd = fd
        epoll_ctl(self._epfd, EPOLL_CTL_ADD, fd, byref(ev))