diff options
author | Seven Du <[email protected]> | 2010-06-16 22:16:57 +0800 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2010-07-07 11:43:10 +0200 |
commit | ebcab38751aee5090093d38904c187d731f0670c (patch) | |
tree | daf364fcd571a0aee1fda29f96923c613392e17c /erts/epmd/src/epmd_cli.c | |
parent | 8495f694672a2bb6d1a4a25f9a93aab5c9fc916b (diff) | |
download | otp-ebcab38751aee5090093d38904c187d731f0670c.tar.gz otp-ebcab38751aee5090093d38904c187d731f0670c.tar.bz2 otp-ebcab38751aee5090093d38904c187d731f0670c.zip |
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) |