~ubuntu-branches/ubuntu/utopic/gridengine/utopic

« back to all changes in this revision

Viewing changes to source/clients/qmon/qmon_start.c

  • Committer: Bazaar Package Importer
  • Author(s): Mark Hymers
  • Date: 2008-06-25 22:36:13 UTC
  • Revision ID: james.westby@ubuntu.com-20080625223613-tvd9xlhuoct9kyhm
Tags: upstream-6.2~beta2
ImportĀ upstreamĀ versionĀ 6.2~beta2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*___INFO__MARK_BEGIN__*/
 
2
/*************************************************************************
 
3
 * 
 
4
 *  The Contents of this file are made available subject to the terms of
 
5
 *  the Sun Industry Standards Source License Version 1.2
 
6
 * 
 
7
 *  Sun Microsystems Inc., March, 2001
 
8
 * 
 
9
 * 
 
10
 *  Sun Industry Standards Source License Version 1.2
 
11
 *  =================================================
 
12
 *  The contents of this file are subject to the Sun Industry Standards
 
13
 *  Source License Version 1.2 (the "License"); You may not use this file
 
14
 *  except in compliance with the License. You may obtain a copy of the
 
15
 *  License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
 
16
 * 
 
17
 *  Software provided under this License is provided on an "AS IS" basis,
 
18
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 
19
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 
20
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 
21
 *  See the License for the specific provisions governing your rights and
 
22
 *  obligations concerning the Software.
 
23
 * 
 
24
 *   The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 
25
 * 
 
26
 *   Copyright: 2001 by Sun Microsystems, Inc.
 
27
 * 
 
28
 *   All Rights Reserved.
 
29
 * 
 
30
 ************************************************************************/
 
31
/*___INFO__MARK_END__*/
 
32
#include <stdio.h>
 
33
#include <stdlib.h>
 
34
#include <unistd.h>
 
35
 
 
36
 
 
37
#include <Xm/Xm.h>
 
38
#include <Xm/MenuShell.h>
 
39
#include <Xm/RowColumn.h>
 
40
#include <Xm/Label.h>
 
41
 
 
42
#include <Xmt/Xmt.h>
 
43
#include <Xmt/WorkingBox.h>
 
44
 
 
45
#include "qmon_rmon.h"
 
46
#include "qmon_start.h"
 
47
#include "qmon_browser.h"
 
48
 
 
49
 
 
50
#if 0
 
51
 
 
52
/*-------------------------------------------------------------------------*/
 
53
static void get_pipe_input(XtPointer cld, int *fid, XtInputId *id);
 
54
static pid_t qmonForkProcess(XtAppContext app, Widget parent);
 
55
 
 
56
/*-------------------------------------------------------------------------*/
 
57
static void get_pipe_input(
 
58
XtPointer cld,
 
59
int *fid,
 
60
XtInputId *id 
 
61
) {
 
62
   char buf[BUFSIZ];
 
63
   int  nbytes;
 
64
 
 
65
   if ((nbytes=read(*fid,buf,BUFSIZ)) == -1)
 
66
      perror("get_pipe_input");
 
67
 
 
68
   fprintf(stderr, "Parent: %s", buf);
 
69
}
 
70
 
 
71
static pid_t qmonForkProcess(
 
72
XtAppContext app,
 
73
Widget parent 
 
74
) {
 
75
   int pfd1[2];
 
76
   pid_t pid;
 
77
   static int count = 0;
 
78
   
 
79
   DENTER(GUI_LAYER, "qmonForkProcess");
 
80
 
 
81
   if ( pipe(pfd1) < 0 ) {
 
82
      fprintf(stderr, "pipe() failed\n");
 
83
      exit(1);
 
84
   }
 
85
   
 
86
   if ((pid = fork()) == -1) {
 
87
      fprintf(stderr, "fork() failed\n");
 
88
   }
 
89
 
 
90
   if (pid == 0) { /* child */
 
91
      close(pfd1[0]);
 
92
      close(1);
 
93
      dup(pfd1[1]);
 
94
      while(1) {
 
95
         if (! (count++ % 1000000) )
 
96
            write(1, "Hello, I'm the child\n", 
 
97
                     strlen("Hello, I'm the child\n")+1);
 
98
      }
 
99
   }
 
100
   else {
 
101
      close(pfd1[1]);
 
102
      XtAppAddInput(app,pfd1[0],(XtPointer)XtInputReadMask,
 
103
                          get_pipe_input, NULL);
 
104
   }
 
105
 
 
106
   DEXIT;
 
107
   return getpid();
 
108
}
 
109
 
 
110
#endif
 
111
 
 
112
 
 
113
/***************************************************************************/
 
114
Widget qmonStartupWindow(
 
115
Widget parent 
 
116
) {
 
117
   Widget StartupShell, StartupRC, StartupLabel;
 
118
   Position x, y;
 
119
 
 
120
   DENTER(TOP_LAYER, "qmonStartupWindow");
 
121
 
 
122
#if 0
 
123
/*
 
124
   fprintf(stderr, "Parent pid = %d\n", 
 
125
            qmonForkProcess(XtWidgetToApplicationContext(parent), parent) );
 
126
*/
 
127
/*
 
128
   StartupShell = XtVaCreateWidget("StartupShell",
 
129
                                    topLevelShellWidgetClass,
 
130
                                    parent,
 
131
                                    XtNtransient,True,
 
132
                                    XtNsaveUnder, True,
 
133
                                    NULL);
 
134
   StartupDialog = XtVaCreateManagedWidget("StartupDialog",
 
135
                                    xmtWorkingBoxWidgetClass,
 
136
                                    StartupShell,
 
137
                                    XmtNmessage, "WELCOME TO SGE",
 
138
                                    XmtNshowScale, False,
 
139
                                    XmtNshowButton, False,
 
140
                                    NULL);
 
141
*/
 
142
#endif
 
143
 
 
144
   x = (DisplayWidth(XtDisplay(parent), DefaultScreen(XtDisplay(parent))) 
 
145
         - 465)/2;
 
146
   y = (DisplayHeight(XtDisplay(parent), DefaultScreen(XtDisplay(parent)))
 
147
         - 730)/2;
 
148
   StartupShell = XtVaCreateWidget( "StartupShell",
 
149
                                    xmMenuShellWidgetClass,
 
150
                                    parent,
 
151
                                    XmNwidth, 465,
 
152
                                    XmNheight, 730,
 
153
                                    XmNx, x,
 
154
                                    XmNy, y,
 
155
                                    NULL);
 
156
   StartupRC = XtVaCreateManagedWidget( "StartupRC",
 
157
                                        xmRowColumnWidgetClass,
 
158
                                        StartupShell,
 
159
                                        XmNx, x,
 
160
                                        XmNy, y,
 
161
                                        XmNwidth, 465,
 
162
                                        XmNheight, 700,
 
163
                                        NULL);
 
164
   StartupLabel = XtVaCreateManagedWidget( "StartupLabel",
 
165
                                        xmLabelWidgetClass,
 
166
                                        StartupRC,
 
167
                                        XmNalignment, XmALIGNMENT_CENTER,
 
168
                                        XmNmarginWidth, 0,
 
169
                                        XmNmarginHeight, 0,
 
170
                                        XmNshadowThickness, 1,
 
171
                                        NULL); 
 
172
   XtRealizeWidget(StartupShell);
 
173
   XtPopup(StartupShell, XtGrabNone);
 
174
   XmtWaitUntilMapped(StartupShell);
 
175
 
 
176
   DEXIT;
 
177
   return StartupShell;
 
178
}