+ /* preapre the pipe */
+ int pipe_ends[] = {0,0};
+ pipe(pipe_ends);
+
+ /* Launch nsupdate */
+ pid_t child_pid = fork();
+ if (child_pid < 0) {
+ std::cerr << "Error while forking." << std::endl;
+ exit(1);
+ }
+ if (child_pid == 0) {
+ /* We're in the child */
+ /* Close write end, use read and as stdin */
+ close(pipe_ends[1]);
+ dup2(pipe_ends[0], fileno(stdin));
+ /* exec nsupdate */
+ execl(nsupdate.c_str(), nsupdate.c_str(), "-k", keyfile.c_str(), NULL);
+ /* There was an error */
+ std::cerr << "There was an error executing nsupdate." << std::endl;
+ exit(1);
+ }
+
+ /* Send it the command */
+ write(pipe_ends[1], "server localhost\n");
+
+ write(pipe_ends[1], "update delete ");
+ write(pipe_ends[1], domain.c_str());
+ write(pipe_ends[1], ".\n");