Previous | Table of Contents | Next

Page 1019

A program may be made portable to all locales by calling setlocale(LC_ALL, """""") after program initialization, by using the values returned from a localeconv() call for locale_dependent information and by using strcoll() or strxfrm() to compare strings.

CONFORMS TO

ANSI C, POSIX.1

Linux supports the portable locales C and POSIX and also the European Latin-1 and Russian locales.

The printf() family of functions may or may not honor the current locale.

SEE ALSO

locale(1), localedef(1), strcoll(3), isalpha(3), localeconv(3), strftime(3), locale(7)

GNU, 18 April 1993

siginterrupt

siginterrupt—Allows signals to interrupt system calls

SYNOPSIS

#include <signal.h>
int siginterrupt(int sig,int flag);

DESCRIPTION

The siginterrupt() function changes the restart behavior when a system call is interrupted by the signal sig.If the flag argument is false (0), then systems calls will be restarted if interrupted by the specified signal sig. This is the default behavior in Linux. However, when a new signal handler is specified with the signal(2) function, the system call is interrupted by default.

If the flag argument is true (1) and no data has been transferred, then a system call interrupted by the signal sig will return

_1 and the global variable errno will be set to EINTR.

If the flag argument is true (1) and data transfer has started, then the system call will be interrupted and will return the actual amount of data transferred.

RETURN VALUE

The siginterrupt() function returns 0 on success, or _1 if the signal number sig is invalid.

ERRORS

EINVAL The specified signal number is invalid.

CONFORMS TO

BSD 4.3

SEE ALSO

signal(2)

13 April 1993

sigemptyset, sigfillset, sigaddset, sigdelset, sigismember

sigemptyset, sigfillset, sigaddset, sigdelset, sigismember—POSIX signal set operations

Page 1020

SYNOPSIS

#include <signal.h>
int sigemptyset(sigset_t *set);
int sigfillset(sigset_t *set);
int sigaddset(sigset_t *set,int signum);
int sigdelset(sigset_t *set,int signum);
int sigismember(const sigset_t *set,int signum);

DESCRIPTION

The sigsetops(3) functions allow the manipulation of POSIX signal sets.

sigemptyset initializes the signal set given by set to empty, with all signals excluded from the set.

sigfillset initializes set to full, including all signals.

sigaddset and sigdelset add and delete, respectively, signal signum from set.

sigismember tests whether signum is a member of set.

RETURN VALUES

sigemptyset, sigfullset, sigaddset, and sigdelset return 0 on success and -1 on error.

sigismember returns 1 if signum is a member of set, 0 if signum is not a member, and -1 on error.

ERRORS

EINVAL sig is not a valid signal.

CONFORMS TO

POSIX

SEE ALSO

sigaction(2), sigpending(2), sigprocmask(2), sigsuspend(2)

Linux 1.0, 24 September 1994

sin

sin—Sine function

SYNOPSIS

#include <math.h>
double sin(double x);

DESCRIPTION

The sin() function returns the sine of x, where x is given in radians.

RETURN VALUE

The sin() function returns a value between _1 and 1.

CONFORMS TO

SVID 3, POSIX, BSD 4.3, ISO 9899

Page 1021

SEE ALSO

acos(3), asin(3), atan(3), atan2(3), cos(3), tan(3)

8 June 1993

sinh

sinh—Hyperbolic sine function

SYNOPSIS

#include <math.h>
double sinh(double x);

DESCRIPTION

The sinh() function returns the hyperbolic sine of x, which is defined mathematically as [exp(x)_exp(-x)] / 2.

CONFORMS TO

SVID 3, POSIX, BSD 4.3, ISO 9899

SEE ALSO

acosh(3), asinh(3), atanh(3), cosh(3), tanh(3)

13 June 1993

sleep

sleep—Sleeps for the specified number of seconds

SYNOPSIS

#include <unistd.h>
unsigned int sleep(unsigned int seconds);

DESCRIPTION

sleep() makes the current process sleep until seconds seconds have elapsed or a signal arrives that is not ignored.

RETURN VALUE

The return value is zero if the requested time has elapsed, or the number of seconds left to sleep.

CONFORMS TO

POSIX.1

BUGS

sleep()may be implemented using SIGALRM; mixing calls to alarm() and sleep() is a bad idea.

Using longjmp() from a signal handler or modifying the handling of SIGALRM while sleeping will cause undefined results.

SEE ALSO

signal(2), alarm(2)

GNU, 7 April 1993

Page 1022

snprintf, vsnprintf

snprintf, vsnprintf—Formatted output conversion

SYNOPSIS

#include <stdio.h>

int snprintf ( char *str, size_t n,
const char *format, ... );

#include <stdarg.h>

int vsnprintf ( char *str, size_t n,
const char *format, va_list ap );

DESCRIPTION

snprintf writes output to the string str, under control of the format string that specifies how subsequent arguments are converted for output. It is similar to sprintf(3), except that n specifies the maximum number of characters to produce.

The trailing null character is counted towards this limit, so you should allocate at least n characters for the string str.

vsnprintf is the equivalent of snprintf with the variable argument list specified directly as for vprintf.

RETURN VALUE

The return value is the number of characters stored, not including the terminating null. If this value equals n, then there was not enough space in str for all the output. You should try again with a bigger output string.

EXAMPLE

Here is a sample program that dynamically enlarges its output buffer:

           /* Construct a message describing the value of a
              variable whose name is NAME and whose value is
              VALUE. */
           char *
           make_message (char *name, char *value)
           {
             /* Guess we need no more than 100 chars of space. */
             int size = 100;
             char *buffer = (char *) xmalloc (size);
             while (1)
               {
                 /* Try to print in the allocated space. */
                 int nchars = snprintf (buffer, size,
                               "value of %s is %s", name, value);
                 /* If that worked, return the string. */
                 if (nchars < size)
                   return buffer;
                 /* Else try again with twice as much space. */
                 size *= 2;
                 buffer = (char *) xrealloc (size, buffer);
               }
           }

CONFORMS TO

These are GNU extensions.

Previous | Table of Contents | Next

1