diff options
author | Raimo Niskanen <[email protected]> | 2010-07-07 11:46:21 +0200 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2010-07-07 11:46:21 +0200 |
commit | 69764c865db61c0351be215f7f36947a71ef82f1 (patch) | |
tree | 3afd851e85535a507df3f2418fe89b7d89b13c82 /erts/epmd/src/epmd_cli.c | |
parent | 661c42ab6f1b014e1988d0b33fda35d9e815ccdb (diff) | |
parent | ebcab38751aee5090093d38904c187d731f0670c (diff) | |
download | otp-69764c865db61c0351be215f7f36947a71ef82f1.tar.gz otp-69764c865db61c0351be215f7f36947a71ef82f1.tar.bz2 otp-69764c865db61c0351be215f7f36947a71ef82f1.zip |
Merge branch 'sd/epmd-stop-cli' into dev
* sd/epmd-stop-cli:
allow epmd -stop name to unregister a client from epmd
Diffstat (limited to 'erts/epmd/src/epmd_cli.c')
-rw-r--r-- | erts/epmd/src/epmd_cli.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/erts/epmd/src/epmd_cli.c b/erts/epmd/src/epmd_cli.c index c12f711bc5..2aed861390 100644 --- a/erts/epmd/src/epmd_cli.c +++ b/erts/epmd/src/epmd_cli.c @@ -54,6 +54,42 @@ void kill_epmd(EpmdVars *g) } } +void stop_cli(EpmdVars *g, char *name) +{ + char buf[1024]; + int fd, rval, bsize; + + bsize = strlen(name); + if (bsize > 1000) { + printf("epmd: Name too long!"); + epmd_cleanup_exit(g, 1); + } + + fd = conn_to_epmd(g); + bsize++; + put_int16(bsize, buf); + buf[2] = EPMD_STOP_REQ; + bsize += 2; + strcpy(buf+3, name); + + if (write(fd, buf, bsize) != bsize) { + printf("epmd: Can't write to epmd\n"); + epmd_cleanup_exit(g,1); + } + if ((rval = read_fill(fd,buf,7)) == 7) { + buf[7] = '\000'; + printf("%s\n", buf); + epmd_cleanup_exit(g,0); + } else if (rval < 0) { + printf("epmd: failed to read answer from local epmd\n"); + epmd_cleanup_exit(g,1); + } else { /* rval is now 0 or 1 */ + buf[rval] = '\0'; + printf("epmd: local epmd responded with <%s>\n", buf); + epmd_cleanup_exit(g,1); + } +} + /* what == EPMD_NAMES_REQ || EPMD_DUMP_REQ */ void epmd_call(EpmdVars *g,int what) |