~mordred/gearmand/solaris-64-fixes

« back to all changes in this revision

Viewing changes to gearmand/gearmand.c

  • Committer: Brian Aker
  • Date: 2009-01-31 23:46:41 UTC
  • mfrom: (19.1.75 fixes)
  • Revision ID: brian@tangent.org-20090131234641-5dxq383nylwcsr8e
MergeĀ Eric.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
 * the COPYING file in the parent directory for full text.
7
7
 */
8
8
 
 
9
#include <errno.h>
9
10
#include <stdio.h>
10
11
#include <stdlib.h>
11
12
#include <unistd.h>
21
22
  gearmand_st *gearmand;
22
23
  gearman_return_t ret;
23
24
 
24
 
  while ((c = getopt(argc, argv, "b:hp:vV")) != EOF)
 
25
  while ((c = getopt(argc, argv, "b:dhp:vV")) != EOF)
25
26
  {
26
27
    switch(c)
27
28
    {
29
30
      backlog= atoi(optarg);
30
31
      break;
31
32
 
 
33
    case 'd':
 
34
      switch (fork())
 
35
      {
 
36
      case -1:
 
37
        fprintf(stderr, "fork:%d\n", errno);
 
38
        return 1;
 
39
 
 
40
      case 0:
 
41
        break;
 
42
 
 
43
      default:
 
44
        return 0;
 
45
      }
 
46
 
 
47
      if (setsid() == -1)
 
48
      {
 
49
        fprintf(stderr, "setsid:%d\n", errno);
 
50
        return 1;
 
51
      }
 
52
 
 
53
      break;
 
54
 
32
55
    case 'p':
33
56
      port= (in_port_t)atoi(optarg);
34
57
      break;
46
69
      printf("\ngearmand %s - %s\n", gearman_version(), gearman_bugreport());
47
70
      printf("usage: %s [-h] [-p <port>]\n", argv[0]);
48
71
      printf("\t-b <backlog> - number of backlog connections for listen\n");
 
72
      printf("\t-d           - detach and run in the background\n");
49
73
      printf("\t-h           - print this help menu\n");
50
74
      printf("\t-p <port>    - port for server to listen on\n");
51
75
      printf("\t-v           - increase verbosity level by one\n");