File: socket.py

package info (click to toggle)
criu 4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,584 kB
  • sloc: ansic: 139,280; python: 7,484; sh: 3,824; java: 2,799; makefile: 2,659; asm: 1,137; perl: 206; xml: 117; exp: 45
file content (21 lines) | stat: -rwxr-xr-x 512 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import os
import socket


def create_fds():
    (sk1, sk2) = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM)
    (sk3, sk4) = socket.socketpair(socket.AF_UNIX, socket.SOCK_STREAM)
    return [(sk1.makefile("wb"), sk2.makefile("rb")),
            (sk3.makefile("wb"), sk4.makefile("rb"))]


def __sock_ino(sockf):
    return os.fstat(sockf.fileno()).st_ino


def filename(sockf):
    return 'socket:[%d]' % __sock_ino(sockf)


def dump_opts(sockf):
    return ['--external', 'unix[%d]' % __sock_ino(sockf)]