git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Version 1.15.10.
[libguestfs.git]
/
fish
/
rc.c
diff --git
a/fish/rc.c
b/fish/rc.c
index
a9eb578
..
31f5c64
100644
(file)
--- a/
fish/rc.c
+++ b/
fish/rc.c
@@
-13,7
+13,7
@@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc.,
675 Mass Ave, Cambridge, MA 02139,
USA.
+ * Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA.
*/
#include <config.h>
*/
#include <config.h>
@@
-66,11
+66,12
@@
receive_stdout (int s)
cmptr = malloc (controllen);
if (NULL == cmptr) {
perror ("malloc");
cmptr = malloc (controllen);
if (NULL == cmptr) {
perror ("malloc");
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
}
/* Don't specify a source */
}
}
/* Don't specify a source */
+ memset (&msg, 0, sizeof msg);
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_name = NULL;
msg.msg_namelen = 0;
@@
-88,7
+89,7
@@
receive_stdout (int s)
ssize_t n = recvmsg (s, &msg, 0);
if (n < 0) {
perror ("recvmsg stdout fd");
ssize_t n = recvmsg (s, &msg, 0);
if (n < 0) {
perror ("recvmsg stdout fd");
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
h = CMSG_FIRSTHDR(&msg);
}
h = CMSG_FIRSTHDR(&msg);
@@
-118,6
+119,7
@@
send_stdout (int s)
char buf[1];
/* Don't specify a destination */
char buf[1];
/* Don't specify a destination */
+ memset (&msg, 0, sizeof msg);
msg.msg_name = NULL;
msg.msg_namelen = 0;
msg.msg_name = NULL;
msg.msg_namelen = 0;
@@
-135,7
+137,7
@@
send_stdout (int s)
cmptr = malloc (controllen);
if (NULL == cmptr) {
perror ("malloc");
cmptr = malloc (controllen);
if (NULL == cmptr) {
perror ("malloc");
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
}
cmptr->cmsg_level = SOL_SOCKET;
}
}
cmptr->cmsg_level = SOL_SOCKET;
@@
-152,7
+154,7
@@
send_stdout (int s)
if (sendmsg (s, &msg, 0) != 1) {
perror ("sendmsg stdout fd");
if (sendmsg (s, &msg, 0) != 1) {
perror ("sendmsg stdout fd");
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
}
}
}
@@
-177,14
+179,15
@@
rc_listen (void)
char sockpath[128];
pid_t pid;
struct sockaddr_un addr;
char sockpath[128];
pid_t pid;
struct sockaddr_un addr;
- int sock, s, i;
+ int sock, s;
+ size_t i;
FILE *fp;
XDR xdr, xdr2;
guestfish_hello hello;
guestfish_call call;
guestfish_reply reply;
char **argv;
FILE *fp;
XDR xdr, xdr2;
guestfish_hello hello;
guestfish_call call;
guestfish_reply reply;
char **argv;
-
in
t argc;
+
size_
t argc;
memset (&hello, 0, sizeof hello);
memset (&call, 0, sizeof call);
memset (&hello, 0, sizeof hello);
memset (&call, 0, sizeof call);
@@
-192,12
+195,17
@@
rc_listen (void)
pid = fork ();
if (pid == -1) {
perror ("fork");
pid = fork ();
if (pid == -1) {
perror ("fork");
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
if (pid > 0) {
/* Parent process. */
}
if (pid > 0) {
/* Parent process. */
- printf ("export GUESTFISH_PID=%d\n", pid);
+
+ if (!remote_control_csh)
+ printf ("GUESTFISH_PID=%d; export GUESTFISH_PID\n", pid);
+ else
+ printf ("setenv GUESTFISH_PID %d\n", pid);
+
fflush (stdout);
_exit (0);
}
fflush (stdout);
_exit (0);
}
@@
-217,16
+225,16
@@
rc_listen (void)
sock = socket (AF_UNIX, SOCK_STREAM, 0);
if (sock == -1) {
perror ("socket");
sock = socket (AF_UNIX, SOCK_STREAM, 0);
if (sock == -1) {
perror ("socket");
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
unlink (sockpath);
if (bind (sock, (struct sockaddr *) &addr, sizeof addr) == -1) {
perror (sockpath);
}
unlink (sockpath);
if (bind (sock, (struct sockaddr *) &addr, sizeof addr) == -1) {
perror (sockpath);
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
if (listen (sock, 4) == -1) {
perror ("listen");
}
if (listen (sock, 4) == -1) {
perror ("listen");
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
/* Now close stdout and substitute /dev/null. This is necessary
}
/* Now close stdout and substitute /dev/null. This is necessary
@@
-265,7
+273,7
@@
rc_listen (void)
argv = realloc (call.args.args_val, (argc+1) * sizeof (char *));
if (argv == NULL) {
perror ("realloc");
argv = realloc (call.args.args_val, (argc+1) * sizeof (char *));
if (argv == NULL) {
perror ("realloc");
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
call.args.args_val = argv;
argv[argc] = NULL;
}
call.args.args_val = argv;
argv[argc] = NULL;
@@
-278,7
+286,7
@@
rc_listen (void)
}
/* Run the command. */
}
/* Run the command. */
- reply.r = issue_command (call.cmd, argv, NULL);
+ reply.r = issue_command (call.cmd, argv, NULL
, 0
);
xdr_free ((xdrproc_t) xdr_guestfish_call, (char *) &call);
xdr_free ((xdrproc_t) xdr_guestfish_call, (char *) &call);
@@
-290,7
+298,7
@@
rc_listen (void)
/* Exit on error? */
if (call.exit_on_error && reply.r == -1) {
unlink (sockpath);
/* Exit on error? */
if (call.exit_on_error && reply.r == -1) {
unlink (sockpath);
- exit (
1
);
+ exit (
EXIT_FAILURE
);
}
}
}
}
@@
-302,12
+310,12
@@
rc_listen (void)
}
unlink (sockpath);
}
unlink (sockpath);
- exit (
0
);
+ exit (
EXIT_SUCCESS
);
}
/* Remote control client. */
int
}
/* Remote control client. */
int
-rc_remote (int pid, const char *cmd,
in
t argc, char *argv[],
+rc_remote (int pid, const char *cmd,
size_
t argc, char *argv[],
int exit_on_error)
{
guestfish_hello hello;
int exit_on_error)
{
guestfish_hello hello;