06-24-2009
a strange segment fault about ltp-posix test
Hi all
In the ltp-posix test,there is a case in open_posix_testsuite\conformance\interfaces\timer_gettime\speculative/6-1.c
Quote:
#include <time.h>
#include <stdio.h>
#include <errno.h>
//#include "posixtest.h"
#define BOGUSTID 9999
int main(int argc, char *argv[])
{
timer_t tid;
struct itimerspec its;
tid = (timer_t) BOGUSTID;
if (timer_gettime(tid, &its) == -1) {
if (EINVAL == errno) {
printf("fcn returned -1 and errno==EINVAL\n");
//return PTS_PASS;
} else {
printf("fcn returned -1 but errno!=EINVAL\n");
printf("Test FAILED\n");
//return PTS_FAIL;
}
}
printf("fcn did not return -1\n");
//return PTS_PASS;
}
I run the above code,it will has a segment fault, if I modify it to below,it works well
Quote:
#include <time.h>
#include <stdio.h>
#include <errno.h>
//#include "posixtest.h"
#define BOGUSTID 9999
int main(int argc, char *argv[])
{
timer_t tid;
struct itimerspec its;
int tval=BOGUSTID;
printf("%d\n",tval);
tid = (timer_t) &tval;
printf("%d\n",tid);
if (timer_gettime(tid, &its) == -1) {
if (EINVAL == errno) {
printf("fcn returned -1 and errno==EINVAL\n");
//return PTS_PASS;
} else {
printf("fcn returned -1 but errno!=EINVAL\n");
printf("Test FAILED\n");
//return PTS_FAIL;
}
}
printf("fcn did not return -1\n");
// return PTS_PASS;
}
Anybody can tell me why?
8 More Discussions You Might Find Interesting
1. Programming
When run it, segment fault.
What is wrong?
#include <stdio.h>
#include <stdlib.h>
const int max =20;
//****************************************************
// Input Matrix
//****************************************************
void inMatrixAA(int *AA, int row, int col)... (9 Replies)
Discussion started by: zhshqzyc
9 Replies
2. Shell Programming and Scripting
Hi all,
I have a script where i need to check the format of a string.
finally, i'm waiting a "process name" and 2 numbers separated by a ","
string like : "this_is_a_string.txt,1,10 should be ok"
string ok : "apache.exe,1,10"
string ok : "mysqld,50,0"
string not ok : "ap ache,1,10"... (4 Replies)
Discussion started by: fgilain
4 Replies
3. Shell Programming and Scripting
I just ran into this today, and don't know what to make of it...
if test x$SERVER = x
then
echo $USAGE
exit 1
fi
I know what everything in there does, except for the 'x' jazz... (2 Replies)
Discussion started by: jjinno
2 Replies
4. Programming
Hi,
Whether the following piece of code is placed in the read-only memory of code (text) segment or data segment?
char *a = "Hello";
I am getting two different answers while searching in google :( that's why the confusion is (7 Replies)
Discussion started by: royalibrahim
7 Replies
5. Programming
I always get segment fault, why? can sb help me and modify it, I have spend on much time on
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>
#include <string.h>
#define MAX 10
pthread_t thread;
void *thread1()
{
int *a;
int i, n;
... (1 Reply)
Discussion started by: yanglei_fage
1 Replies
6. Programming
Hi
I have struggling a week to fix a program , in the begining i got SIGBUS , but after many attempts still the program gets SIGSEGV segment fault , In bellow i post the seg fault log + source codes. would really appreciate if experts help me to fix this segment fault error. any advice is... (2 Replies)
Discussion started by: pooyair
2 Replies
7. Programming
I am trying to reverse complement DNA sequence (string) with a short c++ code using boost library. Code was compiled without any warning/error, but ran into Segmentation fault.
My guess is the function to return a vector, but not sure.
#include <iostream>
#include <fstream>
#include <string>... (14 Replies)
Discussion started by: yifangt
14 Replies
8. Programming
Hello,
This function was copied into my code, which was compiled without error/warning, but when executed there is always Segmentation fault at the end after the output (which seems correct!):
void get_hashes(unsigned int hash, unsigned char *in)
{
unsigned char *str = in;
int pos =... (7 Replies)
Discussion started by: yifangt
7 Replies
uadmin(2) System Calls Manual uadmin(2)
NAME
uadmin - provides administrative control
SYNOPSIS
#include <sys/uadmin.h>
int uadmin(
int cmd,
int fcn,
int mdep );
PARAMETERS
Specifies the type of administrative action to be performed on the system. Specifies the type of action to perform after the system is
shutdown or stopped using A_SHUTDOWN or A_REBOOT.
The available actions are AD_HALT, AD_BOOT, or AD_IBOOT. These are described in more detail below. Specifies machine-dependent
use. It is currently not used and is ignored if defined.
DESCRIPTION
The uadmin function enables control of some basic administrative functions. Mostly, it is called by other system administrative procedures
which must perform automatic shutdowns, halts, and reboots of the system. Using this function as a general interface is not recommended.
To perform a shutdown, halt, or reboot of the system, you must use the cmd parameter which specifies the function to be performed. The val-
ues for the cmd parameter are as follows: Signals that the system stop immediately without any further processing. The operation to be per-
formed next is specified by the fcn parameter. Specifies a remount of the root file system after errors have been resolved. This command
should only be used during the startup process. For this release, this command is unsupported. See the RESTRICTIONS section for more
information. Specifies a systematic shutdown of the system by terminating all user processes, flushing the buffer cache, and unmounting
the root file system. The operation to be performed next must be specified by the fcn parameter.
The fcn parameter specifies the operation that is to be performed after the system has been shutdown or rebooted using the A_SHUTDOWN or
A_REBOOT commands. The fcn parameter has the following values: Halts the processor. The machine is then in a state where power can be
turned off. Reboots the system in standalone mode using the default kernel. Reboots the system in interactive mode. You must provide the
kernel name upon a reboot of the machine.
RESTRICTIONS
Specifying A_REMOUNT is not supported for this release. If it is specified, a value of -1 is returned and errno is set to ENOSYS.
RETURN VALUES
On success, specifying either A_SHUTDOWN or A_REBOOT does not return a value. Specifying A_REMOUNT returns zero (0) on success.
On error, a value of -1 is returned and errno is set to indicate error.
ERRORS
Indicates that a command was specified that is invalid.
uadmin(2)