~ubuntu-branches/ubuntu/precise/gnupg2/precise-proposed

« back to all changes in this revision

Viewing changes to common/exechelp.c

  • Committer: Bazaar Package Importer
  • Author(s): Eric Dorland
  • Date: 2009-03-08 22:46:47 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090308224647-gq17gatcl71lrc2k
Tags: 2.0.11-1
* New upstream release. (Closes: #496663)
* debian/control: Make the description a little more distinctive than
  gnupg v1's. Thanks Jari Aalto. (Closes: #496323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
238
238
    for (i=0,j=1; argv[i]; i++, j++)
239
239
      arg_list[j] = (char*)argv[i];
240
240
 
241
 
  /* Connect the standard files. */
 
241
  /* Assign /dev/null to unused FDs. */
242
242
  for (i=0; i <= 2; i++)
243
243
    {
244
244
      if (fds[i] == -1 )
248
248
            log_fatal ("failed to open `%s': %s\n",
249
249
                       "/dev/null", strerror (errno));
250
250
        }
251
 
      else if (fds[i] != i && dup2 (fds[i], i) == -1)
 
251
    }
 
252
 
 
253
  /* Connect the standard files.  */
 
254
  for (i=0; i <= 2; i++)
 
255
    {
 
256
      if (fds[i] != i && dup2 (fds[i], i) == -1)
252
257
        log_fatal ("dup2 std%s failed: %s\n",
253
258
                   i==0?"in":i==1?"out":"err", strerror (errno));
254
259
    }
351
356
  char *cmdline;
352
357
  int fd, fdout, rp[2];
353
358
 
 
359
  (void)preexec;
 
360
 
354
361
  /* Setup return values.  */
355
362
  *statusfile = NULL;
356
363
  *pid = (pid_t)(-1);
394
401
              | ((flags & 128)? DETACHED_PROCESS : 0)
395
402
              | GetPriorityClass (GetCurrentProcess ())
396
403
              | CREATE_SUSPENDED); 
397
 
  log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline);
 
404
/*   log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); */
398
405
  if (!CreateProcess (pgmname,       /* Program to start.  */
399
406
                      cmdline,       /* Command line arguments.  */
400
407
                      &sec_attr,     /* Process security attributes.  */
419
426
  /* Close the other end of the pipe.  */
420
427
  CloseHandle (fd_to_handle (rp[1]));
421
428
  
422
 
  log_debug ("CreateProcess ready: hProcess=%p hThread=%p"
423
 
             " dwProcessID=%d dwThreadId=%d\n",
424
 
             pi.hProcess, pi.hThread,
425
 
             (int) pi.dwProcessId, (int) pi.dwThreadId);
 
429
/*   log_debug ("CreateProcess ready: hProcess=%p hThread=%p" */
 
430
/*              " dwProcessID=%d dwThreadId=%d\n", */
 
431
/*              pi.hProcess, pi.hThread, */
 
432
/*              (int) pi.dwProcessId, (int) pi.dwThreadId); */
426
433
 
427
434
  /* Process has been created suspended; resume it now. */
428
435
  ResumeThread (pi.hThread);
452
459
  gpg_error_t err;
453
460
  int fd, fdout, rp[2];
454
461
 
 
462
  (void)flags; /* Currently not used.  */
 
463
 
455
464
  *statusfile = NULL;
456
465
  *pid = (pid_t)(-1);
457
466
  fflush (infile);
554
563
  si.hStdOutput = outfd == -1? stdhd[1] : (void*)_get_osfhandle (outfd);
555
564
  si.hStdError  = errfd == -1? stdhd[2] : (void*)_get_osfhandle (errfd);
556
565
 
557
 
  log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline);
 
566
/*   log_debug ("CreateProcess, path=`%s' cmdline=`%s'\n", pgmname, cmdline); */
558
567
  if (!CreateProcess (pgmname,       /* Program to start.  */
559
568
                      cmdline,       /* Command line arguments.  */
560
569
                      &sec_attr,     /* Process security attributes.  */
581
590
  if (err)
582
591
    return err;
583
592
 
584
 
  log_debug ("CreateProcess ready: hProcess=%p hThread=%p"
585
 
             " dwProcessID=%d dwThreadId=%d\n",
586
 
             pi.hProcess, pi.hThread,
587
 
             (int) pi.dwProcessId, (int) pi.dwThreadId);
 
593
/*   log_debug ("CreateProcess ready: hProcess=%p hThread=%p" */
 
594
/*              " dwProcessID=%d dwThreadId=%d\n", */
 
595
/*              pi.hProcess, pi.hThread, */
 
596
/*              (int) pi.dwProcessId, (int) pi.dwThreadId); */
588
597
 
589
598
  /* Process has been created suspended; resume it now. */
590
599
  ResumeThread (pi.hThread);
767
776
     to pass the GPG_AGENT_INFO variable to gpg-agent.  As the default
768
777
     on windows is to use a standard socket, this does not really
769
778
     matter.  */
770
 
 
 
779
  (void)envp;
771
780
 
772
781
  if (access (pgmname, X_OK))
773
782
    return gpg_error_from_syserror ();
792
801
              | GetPriorityClass (GetCurrentProcess ())
793
802
              | CREATE_NEW_PROCESS_GROUP
794
803
              | DETACHED_PROCESS); 
795
 
  log_debug ("CreateProcess(detached), path=`%s' cmdline=`%s'\n",
796
 
             pgmname, cmdline);
 
804
/*   log_debug ("CreateProcess(detached), path=`%s' cmdline=`%s'\n", */
 
805
/*              pgmname, cmdline); */
797
806
  if (!CreateProcess (pgmname,       /* Program to start.  */
798
807
                      cmdline,       /* Command line arguments.  */
799
808
                      &sec_attr,     /* Process security attributes.  */
813
822
  xfree (cmdline);
814
823
  cmdline = NULL;
815
824
 
816
 
  log_debug ("CreateProcess(detached) ready: hProcess=%p hThread=%p"
817
 
             " dwProcessID=%d dwThreadId=%d\n",
818
 
             pi.hProcess, pi.hThread,
819
 
             (int) pi.dwProcessId, (int) pi.dwThreadId);
 
825
/*   log_debug ("CreateProcess(detached) ready: hProcess=%p hThread=%p" */
 
826
/*              " dwProcessID=%d dwThreadId=%d\n", */
 
827
/*              pi.hProcess, pi.hThread, */
 
828
/*              (int) pi.dwProcessId, (int) pi.dwThreadId); */
820
829
 
821
830
  CloseHandle (pi.hThread); 
822
831