summaryrefslogtreecommitdiffstats
path: root/source/lib
diff options
context:
space:
mode:
Diffstat (limited to 'source/lib')
-rw-r--r--source/lib/smbrun.c20
-rw-r--r--source/lib/util_sock.c4
2 files changed, 20 insertions, 4 deletions
diff --git a/source/lib/smbrun.c b/source/lib/smbrun.c
index f8eb9134aed..7162b9266ae 100644
--- a/source/lib/smbrun.c
+++ b/source/lib/smbrun.c
@@ -116,10 +116,26 @@ int smbrun(char *cmd,char *outfile,BOOL shared)
/* in this newer method we will exec /bin/sh with the correct
arguments, after first setting stdout to point at the file */
- if ((pid=fork())) {
+ if ((pid=fork()) < 0) {
+ DEBUG(0,("smbrun: fork failed with error %s\n", strerror(errno) ));
+ return errno;
+ }
+
+ if (pid) {
+ /*
+ * Parent.
+ */
int status=0;
+ pid_t wpid;
+
/* the parent just waits for the child to exit */
- if (sys_waitpid(pid,&status,0) != pid) {
+ while((wpid = sys_waitpid(pid,&status,0)) < 0) {
+ if(errno == EINTR) {
+ errno = 0;
+ continue;
+ }
+ }
+ if (wpid != pid) {
DEBUG(2,("waitpid(%d) : %s\n",pid,strerror(errno)));
return -1;
}
diff --git a/source/lib/util_sock.c b/source/lib/util_sock.c
index a05243d1689..6d395659c92 100644
--- a/source/lib/util_sock.c
+++ b/source/lib/util_sock.c
@@ -679,14 +679,14 @@ int open_socket_in(int type, int port, int dlevel,uint32 socket_addr)
/****************************************************************************
- create an outgoing socket
+ create an outgoing socket. timeout is in milliseconds.
**************************************************************************/
int open_socket_out(int type, struct in_addr *addr, int port ,int timeout)
{
struct sockaddr_in sock_out;
int res,ret;
int connect_loop = 250; /* 250 milliseconds */
- int loops = (timeout * 1000) / connect_loop;
+ int loops = (timeout) / connect_loop;
/* create a socket to write to */
res = socket(PF_INET, type, 0);