hp.com home products and services support and drivers solutions how to buy
cd-rom home
End of Jump to page title
HP OpenVMS systems
documentation

Jump to content


HP C

HP C
Run-Time Library Reference Manual for OpenVMS Systems


Previous Contents Index


seteuid (ALPHA, I64)

Sets the process's effective user ID.

Format

#include <unistd.h>

int seteuid (uid_t euid);


Argument

euid

The value to which you want the effective user ID set.

Description

If the process has the IMPERSONATE privilege, the seteuid function sets the process's effective user ID.

An unprivileged process can set the effective user ID only if the euid argument is equal to either the real, effective, or saved user ID of the process.


Return Values

0 Successful completion.
- 1 Indicates an error. The function sets errno to one of the following values:
  • EINVAL -- The value of the euid argument is invalid and not supported.
  • EPERM -- The process does not have the IMPERSONATE privilege, and euid does not match the real user ID or the saved set-user-ID.

setgid

With POSIX IDs disabled, setgid is implemented for program portability and serves no function. It returns 0 (to indicate success).

With POSIX IDs enabled, setgid sets the group IDs.


Format

#include <types.h>

#include <unistd.h>

int setgid (__gid_t gid); (_DECC_V4_SOURCE)

int setgid (gid_t gid); (NOT _DECC_V4_SOURCE)


Argument

gid

The value to which you want the group IDs set.

Description

The setgid function can be used with POSIX style identifiers enabled or disabled.

POSIX style IDs are supported on OpenVMS Version 7.3-2 and higher.

With POSIX IDs disabled, the setgid function is implemented for program portability and serves no function. It returns 0 (to indicate success).

With POSIX style IDs enabled:

To enable/disable POSIX style IDs, see Section 1.7.


Return Values

0 Successful completion.
- 1 Indicates an error. The function sets errno to one of the following values:
  • EINVAL -- The value of the gid argument is invalid and not supported by the implementation.
  • EPERM -- The process does not have appropriate privileges and gid does not match the real group ID or the saved set-group-ID.

setgrent (ALPHA, I64)

Rewinds the group database.

Format

#include <grp.h>

void setgrent (void);


Description

The setgrent function effectively rewinds the group database to allow repeated searches.

This function is always successful. No value is returned, and errno is not set.


setitimer

Sets the value of interval timers.

Format

#include <time.h>

int setitimer (int which, struct itimerval *value, struct itimerval *ovalue);


Arguments

which

The type of interval timer. The HP C RTL only supports ITIMER_REAL.

value

A pointer to an itimerval structure whose members specify a timer interval and the time left to the end of the interval.

ovalue

A pointer to an itimerval structure whose members specify a current timer interval and the time left to the end of the interval.

Description

The setitimer function sets the timer specified by which to the value specified by value, returning the previous value of the timer if ovalue is nonzero.

A timer value is defined by the itimerval structure:


       struct itimerval { 
               struct  timeval it_interval; 
               struct  timeval it_value; 
       }; 

The value of the itimerval structure members are: as follows
itimerval Member Value Meaning
it_interval = 0 Disables a timer after its next expiration (assumes it_value is nonzero).
it_interval = nonzero Specifies a value used in reloading it_value when the timer expires.
it_value = 0 Disables a timer.
it_value = nonzero Indicates the time to the next timer expiration.

Time values smaller than the resolution of the system clock are rounded up to this resolution.

The getitimer function provides one interval timer, defined in the <time.h> header file as ITIMER_REAL. This timer decrements in real time. When the timer expires, it delivers a SIGALARM signal.

Note

The interaction between setitimer and any of alarm , sleep , or usleep is unspecified.

Return Values

0 Indicates success.
- 1 An error occurred; errno is set to indicate the error.

setjmp

Provides a way to transfer control from a nested series of function invocations back to a predefined point without returning normally. It does not use a series of return statements. The setjmp function saves the context of the calling function in an environment buffer.

Format

#include <setjmp.h>

int setjmp (jmp_buf env);


Argument

env

The environment buffer, which must be an array of integers long enough to hold the register context of the calling function. The type jmp_buf is defined in the <setjmp.h> header file. The contents of the general-purpose registers, including the program counter (PC), are stored in the buffer.

Description

When setjmp is first called, it returns the value 0. If longjmp is then called, naming the same environment as the call to setjmp , control is returned to the setjmp call as if it had returned normally a second time. The return value of setjmp in this second return is the value supplied by you in the longjmp call. To preserve the true value of setjmp , the function calling setjmp must not be called again until the associated longjmp is called.

The setjmp function preserves the hardware general-purpose registers, and the longjmp function restores them. After a longjmp , all variables have their values as of the time of the longjmp except for local automatic variables not marked volatile . These variables have indeterminate values.

The setjmp and longjmp functions rely on the OpenVMS condition-handling facility to effect a nonlocal goto with a signal handler. The longjmp function is implemented by generating a HP C RTL specified signal that allows the OpenVMS condition-handling facility to unwind back to the desired destination.

The HP C RTL must be in control of signal handling for any HP C image. For HP C to be in control of signal handling, you must establish all exception handlers through a call to the VAXC$ESTABLISH function. See Section 4.2.5 and the VAXC$ESTABLISH function for more information.

Note

There are Alpha specific, nonstandard decc$setjmp and decc$fast_longjmp functions. To use these nonstandard functions instead of the standard ones, a program must be compiled with __FAST_SETJMP or __UNIX_SETJMP macros defined.

Unlike the standard longjmp function, the decc$fast_longjmp function does not convert its second argument from 0 to 1. After a call to decc$fast_longjmp , a corresponding setjmp function returns with the exact value of the second argument specified in the decc$fast_longjmp call.

Restrictions

You cannot invoke the longjmp function from an OpenVMS condition handler. However, you may invoke longjmp from a signal handler that has been established for any signal supported by the HP C RTL, subject to the following nesting restrictions:

Return Values

See the Description section.  

setlocale

Selects the appropriate portion of the program's locale as specified by the category and locale arguments. You can use this function to change or query one category or the program's entire current locale.

Format

#include <locale.h>

char *setlocale (int category, const char *locale);


Arguments

category

The name of the category. Specify LC_ALL to change or query the entire locale. Other valid category names are:

locale

Pointer to a string that specifies the locale.

Description

The setlocale function sets or queries the appropriate portion of the program's locale as specified by the category and locale arguments. Specifying LC_ALL for the category argument names the entire locale; specifying the other values name only a portion of the program's locale.

The locale argument points to a character string that identifies the locale to be used. This argument can be one of the following:


Return Values

x Pointer to a string describing the locale.
NULL Indicates an error occurred; errno is set.

Example


#include <errno.h> 
#include <stdio.h> 
#include <locale.h> 
 
/* This program calls setlocale() three times. The second call  */ 
/* is for a nonexistent locale. The third call is for an        */ 
/* existing file that is not a locale file.                     */ 
 
main() 
{ 
    char *ret_str; 
 
    errno = 0; 
    printf("setlocale (LC_ALL, \"POSIX\")"); 
    ret_str = (char *) setlocale(LC_ALL, "POSIX"); 
 
    if (ret_str == NULL) 
        perror("setlocale error"); 
    else 
        printf(" call was successful\n"); 
                                            
    errno = 0; 
    printf("\n\nsetlocale (LC_ALL, \"junk.junk_codeset\")"); 
    ret_str = (char *) setlocale(LC_ALL, "junk.junk_codeset"); 
 
    if (ret_str == NULL) 
        perror(" returned error"); 
    else 
        printf(" call was successful\n"); 
 
    errno = 0; 
    printf("\n\nsetlocale (LC_ALL, \"sys$login:login.com\")"); 
    ret_str = (char *) setlocale(LC_ALL, "sys$login:login.com"); 
 
    if (ret_str == NULL) 
        perror(" returned error"); 
    else 
        printf(" call was successful\n"); 
} 

Running the example program produces the following result:


setlocale (LC_ALL, "POSIX") call was successful 
 
setlocale (LC_ALL, "junk.junk_codeset") 
returned error: no such file or directory 
 
setlocale (LC_ALL, "sys$login:login.com") 
returned error: nontranslatable vms error code: 0x35C07C 
%c-f-localebad, not a locale file 


setpgid (ALPHA, I64)

Sets the process group ID for job control.

Format

#include <unistd.h>

int setpgid (pid_t pid, pid_t pgid);


Arguments

pid

The process ID for which the process group ID is to be set.

pgid

The value to which the process group ID is set.

Description

The setpgid function is used either to join an existing process group or create a new process group within the session of the calling process. The process group ID of a session leader will not change.

Upon successful completion, the process group ID of the process with a process ID of pid is set to pgid. As a special case, if pid is 0, the process ID of the calling process is used. Also, if pgid is 0, the process group ID of the indicated process is used.


Return Values

0 Successful completion.
- 1 Indicates an error. The function sets errno to one of the following values:
  • EACCES -- The value of the pid argument matches the process ID of a child process of the calling process and the child process has successfully executed one of the exec functions.
  • EINVAL -- The value of the pgid argument is less than 0, or is not a value supported by the implementation.
  • EPERM -- The process indicated by the pid argument is a session leader. The value of the pid argument matches the process ID of a child process of the calling process, and the child process is not in the same session as the calling process. The value of the pgid argument is valid but does not match the process ID of the process indicated by the pid argument, and there is no process with a process group ID that matches the value of the pgid argument in the same session as the calling process.
  • ESRCH -- The value of the pid argument does not match the process ID of the calling process or of a child process of the calling process.

setpgrp (ALPHA, I64)

Sets the process group ID.

Format

#include <unistd.h>

pid_t setpgrp (void);


Description

If the calling process is not already a session leader, setpgrp sets the process group ID of the calling process to the process ID of the calling process. If setpgrp creates a new session, then the new session has no controlling terminal.

The setpgrp function has no effect when the calling process is a session leader.


Return Value

x The process group ID of the calling process.


Previous Next Contents Index