× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Hello Rob,

You wrote:
>I had a coworker here working on an iSeries PASE based Tivoli solution. 
>She asked me a question.  She has to issue a 'kill' command to stop a 
>'process id'.  She knows that it is a particular job, like 
>number/user/jobname, however ENDJOB is not the appropriate command.  Is 
>there a way to determine the process id?

There are various Unix shell ways to do this but if you would rather not 
suffer the ugliness of the shell here are some native code examples that 
will do what you want.  The CPPs are in C because that was convenient -- 
you can translate to RPG IV easily enough.

SHWJOBPID:  CMD        PROMPT('Show PID for Job')

            PARM       KWD(JOB) TYPE(Q1) DFT(*) SNGVAL((*)) +
                         PROMPT('Job name')

Q1:         QUAL       TYPE(*NAME) LEN(10) MIN(1) EXPR(*YES)
            QUAL       TYPE(*NAME) LEN(10) MIN(1) EXPR(*YES) +
                         PROMPT('User')
            QUAL       TYPE(*CHAR) LEN(6) RANGE(000001 999999) +
                         MIN(1) FULL(*YES) EXPR(*YES) PROMPT('Number')

#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <qusrjobi.h>

#define BLANKS "                "

int main (int argc, char * argv[] )
{
   struct { char name[10];
            char user[10];
            char number[6];
          } job;
   Qwc_JOBI0800_t jobInfo;
   int i = 0;

   memcpy( &job, argv[1], sizeof(job) );                            

   QUSRJOBI( &jobInfo, sizeof(jobInfo), "JOBI0800", &job, BLANKS ); 

   for ( i=0; i<sizeof(job); i++ )
     if ( job.name[i] == ' ') job.name[i] = '\0';
   printf("PID for job %.6s/%.10s/%.10s is %d\n", job.number,
                                                  job.user,
                                                  job.name,
                                             jobInfo.Process_ID_Number );

   return;
}

SHWPIDJOB:  CMD        PROMPT('Show Job for PID')

            PARM       KWD(PID) TYPE(*INT4) PROMPT('Process +
                         identifier')

#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <Qp0wpid.h>

int main (int argc, char * argv[] )
{
   pid_t pid = *(int*)argv[1];
   QP0W_Job_ID_T jobInfo;
   int rc = 0;
   int i = 0;

   if ( (rc = Qp0wGetJobID( pid, &jobInfo )) == 0 )
   {
      for ( i=0; i<26; i++ )
        if ( jobInfo.jobname[i] == ' ') jobInfo.jobname[i] = '\0';
      printf("Process ID %d is job %.6s/%.10s/%.10s\n", pid,
                                                      jobInfo.jobnumber, 
                                                      jobInfo.username,  
                                                      jobInfo.jobname ); 
   }
   else
    printf("SHWPIDJOB: %s\n", strerror(rc) );

   return;
}

Regards,
Simon Coulter.
--------------------------------------------------------------------
   FlyByNight Software         AS/400 Technical Specialists       
                                                                  
   http://www.flybynight.com.au/                                  
   Phone: +61 3 9419 0175   Mobile: +61 0411 091 400        /"\   
   Fax:   +61 3 9419 0175   mailto: shc@flybynight.com.au   \ /   
                                                             X    
                 ASCII Ribbon campaign against HTML E-Mail  / \   
--------------------------------------------------------------------


As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.