Re: HP-UX 11i how to retrieve long command line of process with C

From: Mike Stroyan (stroyan_at_hpstryn.fc.hp.com)
Date: 06/25/04

  • Next message: Greg Cagle: "Re: Install Tree Foo"
    Date: Fri, 25 Jun 2004 19:58:42 GMT
    
    

    Mike Arnold <marnol01@mail.win.org> wrote:
    |Under HP-UX 11i (and apparently 11.0 with patches PHKL_28202,
    |PHKL_26008, and PHCO_26274), the -x option of the ps command can
    |display 1020 characters of the command line of a process, a vast
    |improvement compared to the previous 63-character limit.

    |Does anyone know the underlying C statements to accomplish this? All
    |my attempts to use pstat_getproc(2) still return only 63 characters,
    |and the pst_cmd element of the pst_status structure is still defined
    |as only 64 characters (via PST_CLEN). Recently, I received a hint
    |that I might have to use the UNIX95 environment variable. If that is
    |true, then I must be using it incorrectly because it hasn't helped.

    A patched ps on 11i v1 uses pstat_getcommandline(). That is not
    available as a documented and supported interface until 11i v1.6 or 11i v2.
    You can read about the call in the system calls section of
    http://www.docs.hp.com./hpux/onlinedocs/B2355-60103/B2355-60103.html

    Here is an example using an unsupported interface on HP-UX 11.11 from
    http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=349348

    #include <sys/pstat.h>
    #include <sys/pstat/pstat_ops.h>
    #define MAX_LENGTH (1024)
    main (argc, argv) int argc; char *argv[]; {
        int pid;
        char long_command [MAX_LENGTH];
        union pstun pu;

        pid = atoi(argv[1]);
        pu.pst_command = long_command;
        if (pstat(PSTAT_GETCOMMANDLINE, pu, MAX_LENGTH, 1, pid) == -1) {
            printf("ERROR: pstat() failure using pid(%d)\n", pid);
            exit(-1);
        }
        printf("pid %d = %s\n", pid, pu.pst_command);
    }

    -- 
    Mike Stroyan, mike.stroyan@hp.com
    

  • Next message: Greg Cagle: "Re: Install Tree Foo"

    Relevant Pages

    • Re: Set App Priority
      ... string and then terminates" ... gives then parameters to use to modify the START command ... below) /F:OFF Disable file and directory name completion characters ... no special characters between the two quote characters, ...
      (microsoft.public.windowsxp.customize)
    • Re: Set App Priority
      ... This would start notepad with high priority. ... Starts a new instance of the Windows XP command interpreter ... /F:OFF Disable file and directory name completion characters ... If all of the following conditions are met, then quote characters ...
      (microsoft.public.windowsxp.customize)
    • Re: DOS Box Keyboard problem
      ... I get 437 from command chcp and cmd chcp. ... When in the cmd box I can type with all characters OK ... The OEMCP value controls to which OEM code page to translate ANSI, ...
      (microsoft.public.windowsxp.configuration_manage)
    • Re: [PATCH] USB: add USB test and measurement class driver - round 2
      ... accumulated (or until zero characters are returned, ... This logic should be done in userspace, ... a measurement command it is not known how many bytes it will return. ... handle this as a warning telling the user that he did not request all ...
      (Linux-Kernel)
    • Re: DOS Box Keyboard problem
      ... Putting the mode con command in config.nt did not work. ... into) Command Prompt windows with a mouse. ... When in the cmd box I can type with all characters OK ...
      (microsoft.public.windowsxp.configuration_manage)