diff options
-rw-r--r-- | vsockclient.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/vsockclient.c b/vsockclient.c index 934cfa0..456810d 100644 --- a/vsockclient.c +++ b/vsockclient.c @@ -41,11 +41,9 @@ int main(int argc, char *argv[]) } } - // Check there are enough positional arguments (two for the - // address and at least one to exec into). - if (optind > argc - 3) + // Find the address (cid and port) to connect to. + if (optind > argc - 2) ex_usage(); - if (getu32(argv[optind++], 0, UINT32_MAX, &rcid)) ex_usage(); if (getu32(argv[optind++], 0, UINT32_MAX, &rport)) @@ -69,6 +67,11 @@ int main(int argc, char *argv[]) "connect to %" PRIu32 ":%" PRIu32 " failed", rcid, rport); ilog("connected to %" PRIu32 ":%" PRIu32 "!", rcid, rport); + // If we have nothing to exec into, we're done. (Sometimes + // just connecting on its own is enough.) + if (optind == argc) + return 0; + // Set up the file descriptors to the well-known UCSPI numbers. if (dup2(fd, 6) == -1) diee(EX_OSERR, "dup2"); |