argc in s6 vs daemontools

2015-03-17 Thread Lorenzo

Hi everyone,

there's a few commands that take N arguments in daemontools and only one 
in s6 - which is a perfectly fine choice, except that most of them 
(think svstat *) will reject no arguments and accept N arguments, but 
only using the 1st one.


These commands are:
- svc
- supervise,svok,svscan? (do the same in the original, so ok)
- svstat
- svscanctl (not in the original)

Here's a boring patch that rejects unused arguments (except for svscan).

---
 src/supervision/s6-supervise.c | 2 +-
 src/supervision/s6-svc.c   | 2 +-
 src/supervision/s6-svok.c  | 2 +-
 src/supervision/s6-svscanctl.c | 2 +-
 src/supervision/s6-svstat.c| 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/supervision/s6-supervise.c b/src/supervision/s6-supervise.c
index 4aaf371..02cdd21 100644
--- a/src/supervision/s6-supervise.c
+++ b/src/supervision/s6-supervise.c
@@ -430,7 +430,7 @@ int main (int argc, char const *const *argv)
 {
   iopause_fd x[2] = { { -1, IOPAUSE_READ, 0 }, { -1, IOPAUSE_READ, 0 } } ;
   PROG = s6-supervise ;
-  if (argc  2) strerr_dieusage(100, USAGE) ;
+  if (argc != 2) strerr_dieusage(100, USAGE) ;
   if (chdir(argv[1])  0) strerr_diefu2sys(111, chdir to , argv[1]) ;
   {
 register unsigned int proglen = str_len(PROG) ;
diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c
index e9396de..1433f79 100644
--- a/src/supervision/s6-svc.c
+++ b/src/supervision/s6-svc.c
@@ -57,7 +57,7 @@ int main (int argc, char const *const *argv, char 
const *const *envp)

 }
 argc -= l.ind ; argv += l.ind ;
   }
-  if (!argc) dieusage() ;
+  if (argc != 1) dieusage() ;
   if (updown[1])
   {
 char const *newargv[11] ;
diff --git a/src/supervision/s6-svok.c b/src/supervision/s6-svok.c
index 4a615e9..7fbe061 100644
--- a/src/supervision/s6-svok.c
+++ b/src/supervision/s6-svok.c
@@ -11,7 +11,7 @@
 int main (int argc, char const *const *argv)
 {
   PROG = s6-svok ;
-  if (argc  2) strerr_dieusage(100, USAGE) ;
+  if (argc != 2) strerr_dieusage(100, USAGE) ;
   argv++ ; argc-- ;
   {
 int fd ;
diff --git a/src/supervision/s6-svscanctl.c b/src/supervision/s6-svscanctl.c
index 6529e9c..13cee5e 100644
--- a/src/supervision/s6-svscanctl.c
+++ b/src/supervision/s6-svscanctl.c
@@ -50,7 +50,7 @@ int main (int argc, char const *const *argv)
 }
 argc -= l.ind ; argv += l.ind ;
   }
-  if (!argc) dieusage() ;
+  if (argc != 1) dieusage() ;

   {
 unsigned int arglen = str_len(*argv) ;
diff --git a/src/supervision/s6-svstat.c b/src/supervision/s6-svstat.c
index de8fe0d..b67a2fe 100644
--- a/src/supervision/s6-svstat.c
+++ b/src/supervision/s6-svstat.c
@@ -40,7 +40,7 @@ int main (int argc, char const *const *argv)
 }
 argc -= l.ind ; argv += l.ind ;
   }
-  if (!argc) dieusage() ;
+  if (argc != 1) dieusage() ;

   if (!s6_svstatus_read(*argv, status))
 strerr_diefu2sys(111, read status for , *argv) ;
--
2.1.4


Re: s6-tcpclient read/write FDs

2015-03-17 Thread Laurent Bercot

On 17/03/2015 16:52, Vincent de RIBOU wrote:

Hi all,
I assume that read and write separate FDs (6 and 7) are only present as 
compliancy with other tools which produce 2 real different FDs.But on TCP is 
not really.
I've made TLS client over s6-tcpclient with wolfSSL. This lib takes only 1 FD 
for context.Since FDs 6 and 7 are same link with s6-tcpclient, I used FD 6 for 
ctx building and it works.
How should I use 2 really different FD's in that context??May I set internal 
unix concept to mux 2 FD's on 1??


 You can simply ignore the second fd, which is just a copy of the first one.
 You can even close(7) at the start of your client and use 6 everywhere, it
will work.

--
 Laurent