Added sys_fork() and sys_getpid() functions to stop the overhead
authorJeremy Allison <jra@samba.org>
Tue, 2 May 2000 02:23:41 +0000 (02:23 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 2 May 2000 02:23:41 +0000 (02:23 +0000)
of doing a system call every time we want to just get our pid.
Jeremy.

38 files changed:
source/auth/pass_check.c
source/client/client.c
source/client/smbmount.c
source/include/proto.h
source/lib/debug.c
source/lib/fault.c
source/lib/genrand.c
source/lib/ms_fnmatch.c
source/lib/pidfile.c
source/lib/smbrun.c
source/lib/substitute.c
source/lib/system.c
source/lib/util.c
source/libsmb/clientgen.c
source/libsmb/namequery.c
source/locking/locking.c
source/nmbd/asyncdns.c
source/nmbd/nmbd.c
source/nmbd/nmbd_packets.c
source/nmbd/nmbd_synclists.c
source/nmbd/nmbd_winsserver.c
source/passdb/pass_check.c
source/passdb/smbpass.c
source/printing/printing.c
source/rpc_server/srv_lsa_hnd.c
source/rpc_server/srv_pipe_hnd.c
source/rpc_server/srv_spoolss_nt.c
source/smbd/chgpasswd.c
source/smbd/connection.c
source/smbd/fileio.c
source/smbd/files.c
source/smbd/negprot.c
source/smbd/open.c
source/smbd/oplock.c
source/smbd/password.c
source/smbd/process.c
source/smbd/server.c
source/smbd/service.c

index c3e56697476929529c5edb710d3bac0f6c234860..0496ed9961f894dd4ffda40add0d924f8f9a490f 100644 (file)
@@ -439,7 +439,7 @@ static BOOL dfs_auth(char *user, char *password)
        }
 
        DEBUG(0, ("DCE login succeeded for principal %s on pid %d\n",
-                 user, getpid()));
+                 user, sys_getpid()));
 
        DEBUG(3, ("DCE principal: %s\n"
                  "          uid: %d\n"
@@ -487,7 +487,7 @@ void dfs_unlogin(void)
                dce_error_inq_text(err, dce_errstr, &err2);
                DEBUG(0,
                      ("DCE purge login context failed for server instance %d: %s\n",
-                      getpid(), dce_errstr));
+                      sys_getpid(), dce_errstr));
        }
 }
 #endif
@@ -595,7 +595,7 @@ static BOOL krb4_auth(char *user, char *password)
        }
 
        (void)slprintf(tkfile, sizeof(tkfile) - 1, "/tmp/samba_tkt_%d",
-                      (int)getpid());
+                      (int)sys_getpid());
 
        krb_set_tkt_string(tkfile);
        if (krb_verify_user(user, "", realm, password, 0, "rmcd") == KSUCCESS)
index ade1436871ca073e4f9f4cac26f958baa22e8ecf..7431b2704e5baa5dce7443b835866a8155832cde 100644 (file)
@@ -849,7 +849,7 @@ static void cmd_more(void)
        fstrcat(rname,"\\");
        slprintf(tmpname,
                 sizeof(fstring)-1,
-                "%s/smbmore.%d",tmpdir(),(int)getpid());
+                "%s/smbmore.%d",tmpdir(),(int)sys_getpid());
        fstrcpy(lname,tmpname);
        
        if (!next_token(NULL,rname+strlen(rname),NULL,sizeof(rname)-strlen(rname))) {
@@ -1159,7 +1159,7 @@ static void cmd_mput(void)
                FILE *f;
                
                slprintf(tmpname,sizeof(pstring)-1,
-                        "%s/ls.smb.%d",tmpdir(),(int)getpid());
+                        "%s/ls.smb.%d",tmpdir(),(int)sys_getpid());
                if (recurse)
                        slprintf(cmd,sizeof(pstring)-1,
                                "find . -name \"%s\" -print > %s",p,tmpname);
@@ -1269,11 +1269,11 @@ static void cmd_print(void)
        pstrcpy(rname,lname);
        p = strrchr(rname,'/');
        if (p) {
-               slprintf(rname, sizeof(rname)-1, "%s-%d", p+1, (int)getpid());
+               slprintf(rname, sizeof(rname)-1, "%s-%d", p+1, (int)sys_getpid());
        }
 
        if (strequal(lname,"-")) {
-               slprintf(rname, sizeof(rname)-1, "stdin-%d", (int)getpid());
+               slprintf(rname, sizeof(rname)-1, "stdin-%d", (int)sys_getpid());
        }
 
        do_put(rname, lname);
index 18af824c1fd5c9c65bc4c4fe12cefc7a7462c6e3..ec3f32bd366717d1658c64662e3a0a85c6070a29 100644 (file)
@@ -72,7 +72,7 @@ static void daemonize(void)
 
        signal( SIGTERM, exit_parent );
 
-       if ((child_pid = fork()) < 0) {
+       if ((child_pid = sys_fork()) < 0) {
                fprintf(stderr,"could not fork\n");
        }
 
@@ -437,7 +437,7 @@ static void init_mount(void)
                args[i++] = xstrdup(tmp);
        }
 
-       if (fork() == 0) {
+       if (sys_fork() == 0) {
                if (file_exist(BINDIR "/smbmnt", NULL)) {
                        execv(BINDIR "/smbmnt", args);
                        fprintf(stderr,"execv of %s failed. Error was %s.", BINDIR "/smbmnt", strerror(errno));
index 6e22fd171f1d554badca300fc7240d98b5a42425..d418ac426819029417c85eedc4437372bae458d4 100644 (file)
@@ -246,6 +246,8 @@ DIR *wsys_opendir(const smb_ucs2_t *wfname);
 smb_ucs2_t *wsys_getwd(smb_ucs2_t *s);
 int wsys_chown(const smb_ucs2_t *wfname, uid_t uid, gid_t gid);
 int wsys_chroot(const smb_ucs2_t *wfname);
+pid_t sys_fork(void);
+pid_t sys_getpid(void);
 int sys_popen(const char *command);
 int sys_pclose(int fd);
 
index ed27b93cfd0ccd79e918464b7717a649eb76a5a6..675c2d8cfcb190bcca275ab66ddc3b3f23544136 100644 (file)
@@ -580,7 +580,7 @@ BOOL dbghdr( int level, char *file, char *func, int line )
        header_str[0] = '\0';
 
        if( lp_debug_pid())
-         slprintf(header_str,sizeof(header_str)-1,", pid=%u",(unsigned int)getpid());
+         slprintf(header_str,sizeof(header_str)-1,", pid=%u",(unsigned int)sys_getpid());
 
        if( lp_debug_uid()) {
       size_t hs_len = strlen(header_str);
index 6effaf7d7c6811854a17710f56629c3ff7a24567..29272f19280a3a9104fda9c1f8966cdc3fe46fee 100644 (file)
@@ -38,7 +38,7 @@ static void fault_report(int sig)
        counter++;
 
        DEBUG(0,("===============================================================\n"));
-       DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)getpid(),VERSION));
+       DEBUG(0,("INTERNAL ERROR: Signal %d in pid %d (%s)",sig,(int)sys_getpid(),VERSION));
        DEBUG(0,("\nPlease read the file BUGS.txt in the distribution\n"));
        DEBUG(0,("===============================================================\n"));
   
index a9698d4cd1b1df6f802f5feb9c8d0a92b666b31c..102eec63009848f4a0753e58f15d31f442497f1e 100644 (file)
@@ -163,7 +163,7 @@ static uint32 do_reseed(unsigned char *md4_outbuf)
    * Finally add the counter, time of day, and pid.
    */
   GetTimeOfDay(&tval);
-  mypid = getpid();
+  mypid = sys_getpid();
   v1 = (counter++) + mypid + tval.tv_sec;
   v2 = (counter++) * mypid + tval.tv_usec;
 
index ee9b1cf985e33efa1075ac57c7116fd8ffb46a3a..364fd6f347a66c3e0d9fca1076eb1d81d3fd5f43 100644 (file)
@@ -36,6 +36,8 @@
    matching routine! 
 
    NOTE: this matches only filenames with no directory component
+
+   Returns 0 on match, -1 on fail.
 */
 int ms_fnmatch(char *pattern, char *string)
 {
index 726e8c1f21aee86998cacb1a9227cd73593f908f..a6dc327fd7a2dd6afa59f54d2ee5cb8347985e78 100644 (file)
@@ -101,7 +101,7 @@ void pidfile_create(char *name)
        }
 
        memset(buf, 0, sizeof(buf));
-       slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int) getpid());
+       slprintf(buf, sizeof(buf) - 1, "%u\n", (unsigned int) sys_getpid());
        if (write(fd, buf, sizeof(buf)) != sizeof(buf)) {
                DEBUG(0,("ERROR: can't write to file %s: %s\n", 
                         pidFile, strerror(errno)));
index 8d666980b38e818c2af23419e39c2b4fa864f7a3..81dfc10dfb11cf27431dc399b940be88bc60a804 100644 (file)
@@ -124,7 +124,7 @@ int smbrun(char *cmd,char *outfile,BOOL shared)
 
        CatchChildLeaveStatus();
                                        
-       if ((pid=fork()) < 0) {
+       if ((pid=sys_fork()) < 0) {
                DEBUG(0,("smbrun: fork failed with error %s\n", strerror(errno) ));
                CatchChild(); 
                return errno;
index c43c133d6ad3ff5bb44335d48ba39d5a799609ae..2a575f0c3820238f3a8f2bfdc2170b5d91b69916 100644 (file)
@@ -176,7 +176,7 @@ void standard_sub_basic(char *str)
                case 'T' : string_sub(p,"%T", timestring(False),l); break;
                case 'a' : string_sub(p,"%a", remote_arch,l); break;
                case 'd' :
-                       slprintf(pidstr,sizeof(pidstr), "%d",(int)getpid());
+                       slprintf(pidstr,sizeof(pidstr), "%d",(int)sys_getpid());
                        string_sub(p,"%d", pidstr,l);
                        break;
                case 'h' : string_sub(p,"%h", myhostname(),l); break;
index 539f21d49c1553f6a605c00dee82e654521307fa..80a968b634cf1d24a4c149cb59ad568a63af83dd 100644 (file)
@@ -932,11 +932,41 @@ static char **extract_args(const char *command)
        return argl;
 }
 
+/**************************************************************************
+ Wrapper for fork. Ensures that mypid is reset. Used so we can write
+ a sys_getpid() that only does a system call *once*.
+****************************************************************************/
+
+static pid_t mypid = (pid_t)-1;
+
+pid_t sys_fork(void)
+{
+       pid_t forkret = fork();
+
+       if (forkret == (pid_t)0) /* Child - reset mypid so sys_getpid does a system call. */
+               mypid = (pid_t) -1;
+
+       return forkret;
+}
+
+/**************************************************************************
+ Wrapper for getpid. Ensures we only do a system call *once*.
+****************************************************************************/
+
+pid_t sys_getpid(void)
+{
+       if (mypid == (pid_t)-1)
+               mypid = getpid();
+
+       return mypid;
+}
+
 /**************************************************************************
  Wrapper for popen. Safer as it doesn't search a path.
  Modified from the glibc sources.
  modified by tridge to return a file descriptor. We must kick our FILE* habit
 ****************************************************************************/
+
 typedef struct _popen_list
 {
        int fd;
@@ -974,7 +1004,7 @@ int sys_popen(const char *command)
        if(!(argl = extract_args(command)))
                goto err_exit;
 
-       entry->child_pid = fork();
+       entry->child_pid = sys_fork();
 
        if (entry->child_pid == -1) {
                goto err_exit;
index 955e1df080a2220860a32316018ce3ee7364f51e..8ac9223f2eb88e4c8b01f261dd494a21da14afc0 100644 (file)
@@ -741,7 +741,7 @@ become a daemon, discarding the controlling terminal
 ****************************************************************************/
 void become_daemon(void)
 {
-       if (fork()) {
+       if (sys_fork()) {
                _exit(0);
        }
 
@@ -1584,7 +1584,7 @@ BOOL fcntl_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type)
     if ((ret != -1) &&
         (lock.l_type != F_UNLCK) && 
         (lock.l_pid != 0) && 
-        (lock.l_pid != getpid()))
+        (lock.l_pid != sys_getpid()))
     {
       DEBUG(3,("fd %d is locked by pid %d\n",fd,(int)lock.l_pid));
       return(True);
@@ -2110,7 +2110,7 @@ int _Insure_trap_error(int a1, int a2, int a3, int a4, int a5, int a6)
        char pidstr[10];
        pstring cmd = "/usr/X11R6/bin/xterm -display :0 -T Panic -n Panic -e /bin/sh -c 'cat /tmp/ierrs.*.%d ; gdb /proc/%d/exe %d'";
 
-       slprintf(pidstr, sizeof(pidstr), "%d", getpid());
+       slprintf(pidstr, sizeof(pidstr), "%d", sys_getpid());
        pstring_sub(cmd, "%d", pidstr);
 
        if (!fn) {
index a3a2483bd55a625064589af79e238c7786acdca7..32564aaf82524b2f9f7a4f53e1b8eb49d5bfd136 100644 (file)
@@ -172,7 +172,7 @@ struct cli_state *cli_initialise(struct cli_state *cli)
        cli->port = 0;
        cli->fd = -1;
        cli->cnum = -1;
-       cli->pid = (uint16)getpid();
+       cli->pid = (uint16)sys_getpid();
        cli->mid = 1;
        cli->vuid = UID_FIELD_INVALID;
        cli->protocol = PROTOCOL_NT1;
index 500a2ff94f9b051609eaa40f7b5b7187f53cef6d..0db1e367dc320e1f80a2b5140e7fa7e464ae41de 100644 (file)
@@ -35,7 +35,7 @@ static int generate_trn_id(void)
        static int trn_id;
 
        if (trn_id == 0) {
-               srandom(getpid());
+               srandom(sys_getpid());
        }
 
        trn_id = random();
index 75198d630330d2268572b5de47eb9b57bca2c1da..47ae917f9af90006ffe90d221f51db29c145d789 100644 (file)
@@ -69,7 +69,7 @@ BOOL is_locked(files_struct *fsp,connection_struct *conn,
                return(False);
 
        ret = !brl_locktest(fsp->dev, fsp->inode, 
-                            global_smbpid, getpid(), conn->cnum, 
+                            global_smbpid, sys_getpid(), conn->cnum, 
                             offset, count, lock_type);
 
        /*
@@ -107,7 +107,7 @@ BOOL do_lock(files_struct *fsp,connection_struct *conn,
 
        if (OPEN_FSP(fsp) && fsp->can_lock && (fsp->conn == conn)) {
                ok = brl_lock(fsp->dev, fsp->inode, fsp->fnum,
-                             global_smbpid, getpid(), conn->cnum, 
+                             global_smbpid, sys_getpid(), conn->cnum, 
                              offset, count, 
                              lock_type);
 
@@ -127,7 +127,7 @@ BOOL do_lock(files_struct *fsp,connection_struct *conn,
                                 * lock entry.
                                 */
                                (void)brl_unlock(fsp->dev, fsp->inode, fsp->fnum,
-                                                               global_smbpid, getpid(), conn->cnum, 
+                                                               global_smbpid, sys_getpid(), conn->cnum, 
                                                                offset, count);
                        }
                }
@@ -170,7 +170,7 @@ BOOL do_unlock(files_struct *fsp,connection_struct *conn,
         */
 
        ok = brl_unlock(fsp->dev, fsp->inode, fsp->fnum,
-                       global_smbpid, getpid(), conn->cnum, offset, count);
+                       global_smbpid, sys_getpid(), conn->cnum, offset, count);
    
        if (!ok) {
                DEBUG(10,("do_unlock: returning ERRlock.\n" ));
@@ -193,7 +193,7 @@ BOOL do_unlock(files_struct *fsp,connection_struct *conn,
 
 void locking_close_file(files_struct *fsp)
 {
-       pid_t pid = getpid();
+       pid_t pid = sys_getpid();
 
        if (!lp_locking(SNUM(fsp->conn)))
                return;
@@ -337,7 +337,7 @@ void del_share_mode(files_struct *fsp)
        struct locking_data *data;
        int i, del_count=0;
        share_mode_entry *shares;
-       pid_t pid = getpid();
+       pid_t pid = sys_getpid();
 
        /* read in the existing share modes */
        dbuf = tdb_fetch(tdb, locking_key_fsp(fsp));
@@ -380,7 +380,7 @@ fill a share mode entry
 static void fill_share_mode(char *p, files_struct *fsp, uint16 port, uint16 op_type)
 {
        share_mode_entry *e = (share_mode_entry *)p;
-       e->pid = getpid();
+       e->pid = sys_getpid();
        e->share_mode = fsp->share_mode;
        e->op_port = port;
        e->op_type = op_type;
@@ -453,7 +453,7 @@ static BOOL mod_share_mode(files_struct *fsp,
        struct locking_data *data;
        int i;
        share_mode_entry *shares;
-       pid_t pid = getpid();
+       pid_t pid = sys_getpid();
        int need_store=0;
 
        /* read in the existing share modes */
index 99e697b470507797de5175191c377b2c509e12b7..1fe04a39e375ab227b5c5a392b11691fd97f3c5b 100644 (file)
@@ -140,7 +140,7 @@ void start_async_dns(void)
                return;
        }
 
-       child_pid = fork();
+       child_pid = sys_fork();
 
        if (child_pid) {
                fd_in = fd1[0];
index c7ebe48822a27f91f375b1cdaf08fd18ca6d22e4..b59a626fff75d93e31973b8791498a12ae231843 100644 (file)
@@ -652,7 +652,7 @@ static void usage(char *pname)
 
   StartupTime = time(NULL);
 
-  sys_srandom(time(NULL) ^ getpid());
+  sys_srandom(time(NULL) ^ sys_getpid());
 
   TimeInit();
 
index a7c94f154460437aa106dd6562587473030eeb20..ee2ba2e240143d98f475e3eefdb663222465943b 100644 (file)
@@ -140,7 +140,7 @@ static uint16 generate_name_trn_id(void)
 
   if (!name_trn_id)
   {
-    name_trn_id = ((unsigned)time(NULL)%(unsigned)0x7FFF) + ((unsigned)getpid()%(unsigned)100);
+    name_trn_id = ((unsigned)time(NULL)%(unsigned)0x7FFF) + ((unsigned)sys_getpid()%(unsigned)100);
   }
   name_trn_id = (name_trn_id+1) % (unsigned)0x7FFF;
   return name_trn_id;
index 7bf17903778be98a0a3eda8d842d727b08ef6083..b69a9959c2273de942388e790c76c09839955c35 100644 (file)
@@ -153,7 +153,7 @@ void sync_browse_lists(struct work_record *work,
        /* the parent forks and returns, leaving the child to do the
           actual sync */
        CatchChild();
-       if ((s->pid = fork())) return;
+       if ((s->pid = sys_fork())) return;
 
        BlockSignals( False, SIGTERM );
 
index 2b99a8ce53bf58d956bd165fe8e1dffc0751bc4a..33b33040cb296f5a8f83dfa94caaf7ce7f000fbc 100644 (file)
@@ -1592,14 +1592,14 @@ void wins_write_database(BOOL background)
      doesn't block while this is done */
   if (background) {
          CatchChild();
-         if (fork()) {
+         if (sys_fork()) {
                  return;
          }
   }
 
   slprintf(fname,sizeof(fname),"%s/%s", lp_lockdir(), WINS_LIST);
   all_string_sub(fname,"//", "/", 0);
-  slprintf(fnamenew,sizeof(fnamenew),"%s.%u", fname, (unsigned int)getpid());
+  slprintf(fnamenew,sizeof(fnamenew),"%s.%u", fname, (unsigned int)sys_getpid());
 
   if((fp = sys_fopen(fnamenew,"w")) == NULL)
   {
index c3e56697476929529c5edb710d3bac0f6c234860..0496ed9961f894dd4ffda40add0d924f8f9a490f 100644 (file)
@@ -439,7 +439,7 @@ static BOOL dfs_auth(char *user, char *password)
        }
 
        DEBUG(0, ("DCE login succeeded for principal %s on pid %d\n",
-                 user, getpid()));
+                 user, sys_getpid()));
 
        DEBUG(3, ("DCE principal: %s\n"
                  "          uid: %d\n"
@@ -487,7 +487,7 @@ void dfs_unlogin(void)
                dce_error_inq_text(err, dce_errstr, &err2);
                DEBUG(0,
                      ("DCE purge login context failed for server instance %d: %s\n",
-                      getpid(), dce_errstr));
+                      sys_getpid(), dce_errstr));
        }
 }
 #endif
@@ -595,7 +595,7 @@ static BOOL krb4_auth(char *user, char *password)
        }
 
        (void)slprintf(tkfile, sizeof(tkfile) - 1, "/tmp/samba_tkt_%d",
-                      (int)getpid());
+                      (int)sys_getpid());
 
        krb_set_tkt_string(tkfile);
        if (krb_verify_user(user, "", realm, password, 0, "rmcd") == KSUCCESS)
index 7aad048339770e22930daa65dcc1ab1f3f4568df..bfb3946b1afe0ab5de02bbeca4af53cbb245930a 100644 (file)
@@ -1106,7 +1106,7 @@ static BOOL del_smbfilepwd_entry(const char *name)
   FILE *fp_write = NULL;
   int pfile2_lockdepth = 0;
 
-  slprintf(pfile2, sizeof(pfile2)-1, "%s.%u", pfile, (unsigned)getpid() );
+  slprintf(pfile2, sizeof(pfile2)-1, "%s.%u", pfile, (unsigned)sys_getpid() );
 
   /*
    * Open the smbpassword file - for update. It needs to be update
index 2f36cf2f3f2fa027b6e8778b0a3665368646148f..95aa50fb431217dae87b1dc9086ac31c8d039e36 100644 (file)
@@ -67,12 +67,12 @@ Does not survive a fork
 ****************************************************************************/
 BOOL print_backend_init(void)
 {
-       if (tdb && local_pid == getpid()) return True;
+       if (tdb && local_pid == sys_getpid()) return True;
        tdb = tdb_open(lock_path("printing.tdb"), 0, 0, O_RDWR|O_CREAT, 0600);
        if (!tdb) {
                DEBUG(0,("Failed to open printing backend database\n"));
        }
-       local_pid = getpid();
+       local_pid = sys_getpid();
 
        /* handle a Samba upgrade */
        tdb_writelock(tdb);
index 937da42ec8b6f8f5f0ef5d69348535d9868d220c..58a7dc6913f5f120356e452bb6c91955a1cbf27b 100644 (file)
@@ -76,7 +76,7 @@ static void create_pol_hnd(POLICY_HND *hnd)
        SIVAL(hnd->data, 4 , pol_hnd_low ); /* second bit is incrementing */
        SIVAL(hnd->data, 8 , pol_hnd_high); /* second bit is incrementing */
        SIVAL(hnd->data, 12, time(NULL)); /* something random */
-       SIVAL(hnd->data, 16, getpid()); /* something more random */
+       SIVAL(hnd->data, 16, sys_getpid()); /* something more random */
 }
 
 /****************************************************************************
index 2d11c5eda51b225488e52d1ecfbe5174eb10851a..7110342383fb6a93904ce68c57ab7739f6ba9a30 100644 (file)
@@ -144,7 +144,7 @@ static void attempt_remote_rpc_connect(pipes_struct *p)
        */
 
        become_root(False); /* to connect to pipe */
-       p->m = msrpc_use_add(p->name, getpid(), &usr, False);
+       p->m = msrpc_use_add(p->name, sys_getpid(), &usr, False);
        unbecome_root(False);
 
        if (p->m == NULL)
@@ -170,7 +170,7 @@ pipes_struct *open_rpc_pipe_p(char *pipe_name,
           log files and prevents client bugs where pipe numbers are reused
           over connection restarts */
        if (next_pipe == 0)
-               next_pipe = (getpid() ^ time(NULL)) % MAX_OPEN_PIPES;
+               next_pipe = (sys_getpid() ^ time(NULL)) % MAX_OPEN_PIPES;
 
        i = bitmap_find(bmap, next_pipe);
 
index 1daa7e55da6ca0459a7d43dd203dc5637d7625d0..2680c3a553d06b8949554a309842731cefa0cf55 100644 (file)
@@ -135,7 +135,7 @@ static void create_printer_hnd(POLICY_HND *hnd)
        SIVAL(hnd->data, 4 , prt_hnd_low ); /* second bit is incrementing */
        SIVAL(hnd->data, 8 , prt_hnd_high); /* second bit is incrementing */
        SIVAL(hnd->data, 12, time(NULL));   /* something random */
-       SIVAL(hnd->data, 16, getpid());     /* something more random */
+       SIVAL(hnd->data, 16, sys_getpid());     /* something more random */
 }
 
 /****************************************************************************
index 484523bd2726457c0d363f9e1816dd8a18d68f40..708b52f4bcdc30802585e74e2371baf02c5088fd 100644 (file)
@@ -330,7 +330,7 @@ static BOOL chat_with_program(char *passwordprogram, char *name,
 
        CatchChildLeaveStatus();
 
-       if ((pid = fork()) < 0)
+       if ((pid = sys_fork()) < 0)
        {
                DEBUG(3,
                      ("Cannot fork() child for password change: %s\n",
index 9c859e4d8962c36d0062d2113452364f370d916c..aa49f8cf7cf3527e03ef7b1a019436944a64ce4b 100644 (file)
@@ -45,7 +45,7 @@ BOOL yield_connection(connection_struct *conn,char *name,int max_connections)
        DEBUG(3,("Yielding connection to %s\n",name));
 
        ZERO_STRUCT(key);
-       key.pid = getpid();
+       key.pid = sys_getpid();
        if (conn) key.cnum = conn->cnum;
        fstrcpy(key.name, name);
 
@@ -84,7 +84,7 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
        DEBUG(5,("claiming %s %d\n",name,max_connections));
 
        ZERO_STRUCT(key);
-       key.pid = getpid();
+       key.pid = sys_getpid();
        key.cnum = conn?conn->cnum:-1;
        fstrcpy(key.name, name);
 
@@ -94,7 +94,7 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO
        /* fill in the crec */
        ZERO_STRUCT(crec);
        crec.magic = 0x280267;
-       crec.pid = getpid();
+       crec.pid = sys_getpid();
        crec.cnum = conn?conn->cnum:-1;
        if (conn) {
                crec.uid = conn->uid;
index 8f8f17563e448d36a1466e82bf5f6e849e44ace2..2d83378b3dee6a6b1b535c9f74dff9abc368fc35 100644 (file)
@@ -205,7 +205,7 @@ ssize_t write_file(files_struct *fsp, char *data, SMB_OFF_T pos, size_t n)
 
   if (LEVEL_II_OPLOCK_TYPE(fsp->oplock_type)) {
     share_mode_entry *share_list = NULL;
-    pid_t pid = getpid();
+    pid_t pid = sys_getpid();
     int token = -1;
     int num_share_modes = 0;
     int i;
index e644f52669fca1ff6805e03f5623a2d93a65616c..5b930f994009759489cc8e76f1cd657617871b78 100644 (file)
@@ -55,7 +55,7 @@ files_struct *file_new(void )
           increases the chance that the errant client will get an error rather
           than causing corruption */
        if (first_file == 0) {
-               first_file = (getpid() ^ (int)time(NULL)) % real_max_open_files;
+               first_file = (sys_getpid() ^ (int)time(NULL)) % real_max_open_files;
        }
 
        i = bitmap_find(file_bmap, first_file);
index adef4a57f376107792796d17e8517d45ede065d7..e8302a43e6ba9b9674c1cf23bbae33f63b0563fe 100644 (file)
@@ -87,7 +87,7 @@ static int reply_lanman1(char *outbuf)
   SSVAL(outbuf,smb_vwv4,1);
   SSVAL(outbuf,smb_vwv5,raw); /* tell redirector we support
                                 readbraw writebraw (possibly) */
-  SIVAL(outbuf,smb_vwv6,getpid());
+  SIVAL(outbuf,smb_vwv6,sys_getpid());
   SSVAL(outbuf,smb_vwv10, TimeDiff(t)/60);
 
   put_dos_date(outbuf,smb_vwv8,t);
@@ -133,7 +133,7 @@ static int reply_lanman2(char *outbuf)
 
   set_message(outbuf,13,crypt_len,True);
   SSVAL(outbuf,smb_vwv1,secword); 
-  SIVAL(outbuf,smb_vwv6,getpid());
+  SIVAL(outbuf,smb_vwv6,sys_getpid());
   if (doencrypt) 
          memcpy(smb_buf(outbuf), cryptkey, 8);
 
@@ -226,7 +226,7 @@ static int reply_nt1(char *outbuf)
   SSVAL(outbuf,smb_vwv2+1,1); /* num vcs */
   SIVAL(outbuf,smb_vwv3+1,0xffff); /* max buffer. LOTS! */
   SIVAL(outbuf,smb_vwv5+1,0x10000); /* raw size. full 64k */
-  SIVAL(outbuf,smb_vwv7+1,getpid()); /* session key */
+  SIVAL(outbuf,smb_vwv7+1,sys_getpid()); /* session key */
   SIVAL(outbuf,smb_vwv9+1,capabilities); /* capabilities */
   put_long_date(outbuf+smb_vwv11+1,t);
   SSVALS(outbuf,smb_vwv15+1,TimeDiff(t)/60);
index 9aadb39bc9775b93ebc8eae7200a43b8fd7244da..0c6927ba2a7596cf1ac768865c953943cc579507 100644 (file)
@@ -342,7 +342,7 @@ static int check_share_mode( share_mode_entry *share, int deny_mode,
 
        {
                int access_allowed = access_table(deny_mode,old_deny_mode,old_open_mode,
-                                                                               (share->pid == getpid()),is_executable(fname));
+                                                                               (share->pid == sys_getpid()),is_executable(fname));
 
                if ((access_allowed == AFAIL) ||
                        (!fcbopen && (access_allowed == AREAD && *flags == O_RDWR)) ||
@@ -946,7 +946,7 @@ BOOL check_file_sharing(connection_struct *conn,char *fname, BOOL rename_op)
   share_mode_entry *old_shares = 0;
   int num_share_modes;
   SMB_STRUCT_STAT sbuf;
-  pid_t pid = getpid();
+  pid_t pid = sys_getpid();
   SMB_DEV_T dev;
   SMB_INO_T inode;
 
index 28ab29d02747b0b9594ae74a69c58e45821307a7..4a363d45e98b0711ca1711cc741a985d5c73c85e 100644 (file)
@@ -111,7 +111,7 @@ address %lx. Error was %s\n", (long)htonl(INADDR_LOOPBACK), strerror(errno)));
     return False;
 
   DEBUG(3,("open_oplock ipc: pid = %d, global_oplock_port = %u\n", 
-            (int)getpid(), global_oplock_port));
+            (int)sys_getpid(), global_oplock_port));
 
   return True;
 }
@@ -1088,7 +1088,7 @@ BOOL request_oplock_break(share_mode_entry *share_entry,
 {
   char op_break_msg[OPLOCK_BREAK_MSG_LEN];
   struct sockaddr_in addr_out;
-  pid_t pid = getpid();
+  pid_t pid = sys_getpid();
   time_t start_time;
   int time_left;
   long usec;
@@ -1342,7 +1342,7 @@ void check_kernel_oplocks(void)
     set_process_capability(KERNEL_OPLOCK_CAPABILITY,True);
     set_inherited_process_capability(KERNEL_OPLOCK_CAPABILITY,True);
 
-       slprintf(tmpname,sizeof(tmpname)-1, "%s/koplock.%d", lp_lockdir(), (int)getpid());
+       slprintf(tmpname,sizeof(tmpname)-1, "%s/koplock.%d", lp_lockdir(), (int)sys_getpid());
 
     if(pipe(pfd) != 0) {
       DEBUG(0,("check_kernel_oplocks: Unable to create pipe. Error was %s\n",
index f92d31718c2dcbf3e91858faba5fd1db9af66055..a8b9050030f0f7dacfbbaad155e6c33cfd4ab22a 100644 (file)
@@ -53,8 +53,8 @@ void generate_next_challenge(char *challenge)
 
        /* get a sort-of random number */
        GetTimeOfDay(&tval);
-       v1 = (counter++) + getpid() + tval.tv_sec;
-       v2 = (counter++) * getpid() + tval.tv_usec;
+       v1 = (counter++) + sys_getpid() + tval.tv_sec;
+       v2 = (counter++) * sys_getpid() + tval.tv_usec;
        SIVAL(challenge,0,v1);
        SIVAL(challenge,4,v2);
 
index b81e8311337f4762e4cb44a4f2c3749f873f2345..1eb58996678aff8511922e355d555630f5d1bc8a 100644 (file)
@@ -421,7 +421,7 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
   extern int global_smbpid;
 
   if (pid == (pid_t)-1)
-    pid = getpid();
+    pid = sys_getpid();
 
   errno = 0;
   last_message = type;
index 8e4de78cbfa5c3c1b64e05baaaf37f18804da982..574be64553ac754013a410c1ff760543cf100848 100644 (file)
@@ -238,7 +238,7 @@ max can be %d\n",
                                continue;
                        }
                        
-                       if (smbd_server_fd() != -1 && fork()==0) {
+                       if (smbd_server_fd() != -1 && sys_fork()==0) {
                                /* Child code ... */
                                
                                /* close the listening socket(s) */
index 8e04f7e9896d3a2426b78c87bf5354b4ee1ce847..ebc4c9a79012e2b755be0f49c58770817487ff68 100644 (file)
@@ -608,7 +608,7 @@ connection_struct *make_connection(char *service,char *user,char *password, int
                dbgtext( "connect to service %s ", lp_servicename(SNUM(conn)) );
                dbgtext( "as user %s ", user );
                dbgtext( "(uid=%d, gid=%d) ", (int)geteuid(), (int)getegid() );
-               dbgtext( "(pid %d)\n", (int)getpid() );
+               dbgtext( "(pid %d)\n", (int)sys_getpid() );
        }
        
        /* we've finished with the sensitive stuff */