Host control socket: a client that disconnects early kills vphone-cli with SIGPIPE
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 74/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- swift
- Domain
- cli, operating-systems
Research direction
Start in sources/vphone-cli/VPhoneHostControl.swift at VPhoneHostControl.writeResponse and the client setup after accept. Run the Python UNIX-socket reproduction from the issue, then verify that an early-disconnecting client no longer terminates vphone-cli. Also inspect the file’s command documentation and screenshot handling to resolve the stated screen:false discrepancy.
Written by the indexing model from the issue text.
Description
What happens
The VM exits when a host-control client disconnects before it has read the whole reply. The process exits silently: there is no crash report, and the launch log shows only the wrapper's exit diagnosis. The next connection to vphone.sock is refused.
This happened four times on 2026-09-17, each time right after a {"t":"screenshot","path":...} request.
Cause
VPhoneHostControl.writeResponse (sources/vphone-cli/VPhoneHostControl.swift, at 87f796c) calls write(2) in a loop on the client socket. Nothing in the process ignores SIGPIPE, and the socket does not set SO_NOSIGPIPE. When the peer has already closed the socket, the next write raises SIGPIPE, which kills vphone-cli and the VM with it.
The reply to a screenshot request is large, because the handler always attaches the base64 compact image (result.imageBase64 = await controller.captureCompactScreenshot()). A client that calls recv(4096) once and then closes is therefore enough to kill the VM:
s = socket.socket(socket.AF_UNIX)
s.connect(os.path.expanduser("~/.vphone/VMs/vphone/vphone.sock"))
s.sendall(b'{"t":"screenshot","path":"/tmp/x.png","screen":false}\n')
s.recv(4096)
s.close()
The cause was found by reading the code; no crash was captured during the failures.
Suggested fix
- Set
setsockopt(clientFD, SOL_SOCKET, SO_NOSIGPIPE, ...)afteraccept, or callsignal(SIGPIPE, SIG_IGN)once at startup.writeResponsealready stops whenwritereturns a value<= 0, so anEPIPEthere would end the request quietly. - The
screenshotcommand ignores"screen":false, although the doc comment at the top of the file says every command respects it. Either honor the flag forscreenshotor state in the doc comment that this command ignores it.
- Dominant language
- Swift
- Stars
- 14k
- Forks
- 1.7k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 9
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Lakr233/vphone-cli
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Lakr233/vphone-cli#483 ·
-
Tried on AWS ec2? Open
Difficulty 5/5 Over a week Newbie friendliness 20/100
Lakr233/vphone-cli#482 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
Lakr233/vphone-cli#481 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
Lakr233/vphone-cli#471 ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
Lakr233/vphone-cli#470 ·
All issues in Lakr233/vphone-cli
Similar issues
-
type: docs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
googleapis/google-cloud-swift#971 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bitcoindevkit/bdk-ffi#1125 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mozilla-mobile/firefox-ios#35743 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
manaflow-ai/cmux#13417 ·
-
triage
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
ionic-team/capacitor#8616 ·