Skip to content

Commit

Permalink
Remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
kovidgoyal committed Jan 5, 2025
1 parent 25cb735 commit a410d38
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 49 deletions.
20 changes: 0 additions & 20 deletions kitty/child-monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2042,28 +2042,8 @@ send_data_to_peer(PyObject *self UNUSED, PyObject *args) {
Py_RETURN_NONE;
}

static PyObject *
random_unix_socket(PyObject *self UNUSED, PyObject *args UNUSED) {
#ifndef SO_PASSCRED
errno = ENOTSUP;
return PyErr_SetFromErrno(PyExc_OSError);
#else
int fd, optval = 1;
struct sockaddr_un bind_addr = {.sun_family=AF_UNIX};
fd = socket(AF_UNIX, SOCK_STREAM, 0);
if (fd < 0) return PyErr_SetFromErrno(PyExc_OSError);
if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &optval, sizeof optval) != 0) goto fail;
if (bind(fd, (struct sockaddr *)&bind_addr, sizeof(sa_family_t)) != 0) goto fail;
return PyLong_FromLong((long)fd);
fail:
safe_close(fd, __FILE__, __LINE__);
return PyErr_SetFromErrno(PyExc_OSError);
#endif
}

static PyMethodDef module_methods[] = {
METHODB(safe_pipe, METH_VARARGS),
METHODB(random_unix_socket, METH_NOARGS),
{"add_timer", (PyCFunction)add_python_timer, METH_VARARGS, ""},
{"remove_timer", (PyCFunction)remove_python_timer, METH_VARARGS, ""},
METHODB(monitor_pid, METH_VARARGS),
Expand Down
4 changes: 0 additions & 4 deletions kitty/fast_data_types.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1591,10 +1591,6 @@ def sigqueue(pid: int, signal: int, value: int) -> None:
pass


def random_unix_socket() -> int:
pass


def read_signals(fd: int, callback: Callable[[SignalInfo], None]) -> None:
pass

Expand Down
25 changes: 0 additions & 25 deletions kitty/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,31 +383,6 @@ def unix_socket_paths(name: str, ext: str = '.lock') -> Generator[str, None, Non
yield os.path.join(loc, filename)


def random_unix_socket() -> 'Socket':
import shutil
import socket
import stat
import tempfile

from kitty.fast_data_types import random_unix_socket as rus
try:
fd = rus()
except OSError:
for path in unix_socket_directories():
ans = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_STREAM, proto=0)
tdir = tempfile.mkdtemp(prefix='.kitty-', dir=path)
atexit.register(remove_socket_file, ans, tdir, shutil.rmtree)
path = os.path.join(tdir, 's')
ans.bind(path)
os.chmod(path, stat.S_IRUSR | stat.S_IWUSR)
break
else:
ans = socket.socket(family=socket.AF_UNIX, type=socket.SOCK_STREAM, proto=0, fileno=fd)
ans.set_inheritable(False)
ans.setblocking(False)
return ans


def parse_address_spec(spec: str) -> tuple[AddressFamily, Union[tuple[str, int], str], Optional[str]]:
import socket
try:
Expand Down

0 comments on commit a410d38

Please sign in to comment.