// Licensed under the Apache License, Version 2.0 (the "License"); you may not // use this file except in compliance with the License. You may obtain a copy of // the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations under // the License. // Do what 2 lines of shell script in couchspawnkillable does... // * Create a new suspended process with the same (duplicated) standard // handles as us. // * Write a line to stdout, consisting of the path to ourselves, plus // '--kill {pid}' where {pid} is the PID of the newly created process. // * Un-suspend the new process. // * Wait for the process to terminate. // * Terminate with the child's exit-code. // Later, couch will call us with --kill and the PID, so we dutifully // terminate the specified PID. #include #include "windows.h" char *get_child_cmdline(int argc, char **argv) { // make a new command-line, but skipping me. // XXX - todo - spaces etc in args??? int i; char *p, *cmdline; int nchars = 0; int nthis = 1; for (i=1;i