|
Lines 166-176
def pidof(name, docker='/var/run/docker.pid'):
Link Here
|
| 166 |
stat = os.path.join('/proc', proc, 'stat') |
166 |
stat = os.path.join('/proc', proc, 'stat') |
| 167 |
try: |
167 |
try: |
| 168 |
with open(stat, 'r') as fd: |
168 |
with open(stat, 'r') as fd: |
| 169 |
status = fd.read() |
169 |
status = fd.readline() |
| 170 |
ppid = int(status.split()[3], 10) |
170 |
ppid = int(status.split(')', 1)[-1].split()[1], 10) |
| 171 |
children.setdefault(ppid, []).append(pid) |
171 |
children.setdefault(ppid, []).append(pid) |
| 172 |
except (EnvironmentError, ValueError) as ex: |
172 |
except (EnvironmentError, ValueError) as ex: |
| 173 |
log.error('Failed getting parent: %s', ex) |
173 |
log.error('Failed getting parent: %s: %r', ex, status) |
| 174 |
|
174 |
|
| 175 |
def _running(): |
175 |
def _running(): |
| 176 |
yield cmd == [link] |
176 |
yield cmd == [link] |