The system is actually supposed to crash when you do this, rather than let you get away with mangling data outside of bounds, but some systems are better at catching it than others.
sometimes for this code i get a segmentation fault for codes llike this
:
int main{
int * a= 0;
int b;
a = (int*)malloc(sizeof(int));
///some code using these variable but no freeing of a
if(a){
free(a);
a = 0;
}
return... (3 Replies)
Hi ,
During execution a backup binary i get following error
"Program error 11 (Segmentation fault), saving core file in '/usr/datatools"
Riyaz (2 Replies)
Hi,
on a linux Red HAT(with Oracle DB 9.2.0.7) I have following error :
RMAN> delete obsolete;
RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 2
using channel ORA_DISK_1
Segmentation fault
What does it mean ? And the solution ?
Many thanks. (0 Replies)
If I do this.
Assume
struct life
{
char *nolife;
}
struct life **life;
// malloc initialization & everything
if(life->nolife == 0)
Would I get error at life->nolife if it is equal to 0.
wrong accession? (3 Replies)
I'm getting a segmentation fault. I'm new to Linux programming. Thanks so much for all of your input.:eek:
#include </usr/include/mysql++/mysql++.h>
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <string.h>
using namespace std;
int outputToImport(const char*... (1 Reply)
i have this code
int already_there(char *client_names, char *username) {
int i;
for(i = 0; i<NUM; i++) {
printf("HERE\n");
if (strcmp(client_names, username)==0) return(1);
}
return(0);
}
and i get a segmentation fault, whats wrong here? (7 Replies)
I use a binary name (ie polo) it gets some parameter , so for debugging normally i do this :
i wrote script for watchdog my app (polo) and check every second if it's not running then start it , the problem is , if my app , remain in state of segmentation fault for a while (ie 15 ... (6 Replies)
this is a network programming code to run a rock paper scissors in a client and server.
I completed it and it was working without any error. After I added the findWinner function to the server code it starts giving me segmentation fault.
-the segmentation fault is fixed
Current problem -Also... (3 Replies)
Hi Guys,
I just installed and booted a zone called testzone. When I logged in remotely and tried changing to root user I get this error:
"Segmentation fault"
Can someone please help me resolve this?
Thanks alot (2 Replies)
Discussion started by: cjashu
2 Replies
LEARN ABOUT MINIX
getopt
GETOPT(3) Library Functions Manual GETOPT(3)NAME
getopt - get option letter from argv
SYNOPSIS
int getopt(argc, argv, optstring)
int argc;
char **argv;
char *optstring;
extern char *optarg;
extern int optind;
DESCRIPTION
Getopt returns the next option letter in argv that matches a letter in optstring. Optstring is a string of recognized option letters; if a
letter is followed by a colon, the option is expected to have an argument that may or may not be separated from it by white space. Optarg
is set to point to the start of the option argument on return from getopt.
Getopt places in optind the argv index of the next argument to be processed. Because optind is external, it is normally initialized to
zero automatically before the first call to getopt.
When all options have been processed (i.e., up to the first non-option argument), getopt returns EOF. The special option -- may be used to
delimit the end of the options; EOF will be returned, and -- will be skipped.
DIAGNOSTICS
Getopt prints an error message on stderr and returns a question mark (?) when it encounters an option letter not included in optstring.
EXAMPLE
The following code fragment shows how one might process the arguments for a command that can take the mutually exclusive options a and b,
and the options f and o, both of which require arguments:
main(argc, argv)
int argc;
char **argv;
{
int c;
extern int optind;
extern char *optarg;
.
.
.
while ((c = getopt(argc, argv, "abf:o:")) != EOF)
switch (c) {
case `a':
if (bflg)
errflg++;
else
aflg++;
break;
case `b':
if (aflg)
errflg++;
else
bproc();
break;
case `f':
ifile = optarg;
break;
case `o':
ofile = optarg;
break;
case `?':
default:
errflg++;
break;
}
if (errflg) {
fprintf(stderr, "Usage: ...");
exit(2);
}
for (; optind < argc; optind++) {
.
.
.
}
.
.
.
}
HISTORY
Written by Henry Spencer, working from a Bell Labs manual page. Modified by Keith Bostic to behave more like the System V version.
BUGS
It is not obvious how `-' standing alone should be treated; this version treats it as a non-option argument, which is not always right.
Option arguments are allowed to begin with `-'; this is reasonable but reduces the amount of error checking possible.
Getopt is quite flexible but the obvious price must be paid: there is much it could do that it doesn't, like checking mutually exclusive
options, checking type of option arguments, etc.
4.3 Berkeley Distribution May 27, 1986 GETOPT(3)