01-01-2009
[C] fgets problem with SIGINT singlal!!!
Hi all,
I have this method to read a string from a STDIN:
PHP Code:
void readLine(char* inputBuffer){
fgets (inputBuffer, MAX_LINE, stdin);
fflush(stdin);
/* remove '\n' char from string */
if(strlen(inputBuffer) != 0)
inputBuffer[strlen(inputBuffer)-1] = '\0';
}
All work fine but if i catch SIGINT signal (CTRL+C) with this method:
PHP Code:
void handle_SIGNINT(){
/* here i don't want exit with program!!! */
}
i would like that "fgets's wait" was released when there is a signal....now to realese it i need press ENTER KEY!!!, how can i do in automate?
can i "simulate" the ENTER key pressed writing a particular ASCII char into STDIN???
Thanks a lot in advance, Martin
10 More Discussions You Might Find Interesting
1. Programming
does anyone knows how to accept a command from a user.. i was wondering to use fgets(), but got no idea how to start it... (4 Replies)
Discussion started by: skanky
4 Replies
2. Programming
Hello Friends,
I got stuck with fgets () & rewind() function .. Please need help..
Actually I am doing a like,
The function should read lines from a txt file until the function is called..
If the data from the txt file ends then it goes to the top and then again when the function is called... (1 Reply)
Discussion started by: user_prady
1 Replies
3. Programming
For a program I am designing, which involves handling the keyboard input Ctrl^c (SIGINT), it is taking ages for the program to actually recognise and perform the corresponding action whenever I run it and hit Ctrl^C at the CL. I have to do at least 3 Ctrl^Cs before the program will actually... (3 Replies)
Discussion started by: JamesGoh
3 Replies
4. Programming
Assume client send the message " Hello ", i get output such as
Sent mesg: hello
Bytes Sent to Client: 6
bytes_received = recv(clientSockD, data, MAX_DATA, 0);
if(bytes_received)
{
send(clientSockD, data, bytes_received, 0);
data = '\0';... (2 Replies)
Discussion started by: f.ben.isaac
2 Replies
5. Shell Programming and Scripting
I've written a bash script which captures video with DVgrab. Because of the nature of the tapes that I am digitizing, sometimes I want to quit capturing before the time that I set for DVgrab. When this is the case I press Ctrl-c and DVgrab exits cleanly, my problem is that there is additional... (5 Replies)
Discussion started by: Starcast
5 Replies
6. Programming
hi,
in my application, i have set up to capture SIGINT and execute a handler.the problem is whenever i hit C-c, multiple SIGINT are sent to the application.I have blocked the SIGINT right after catching the first one but it is unsuccessful.Here is what i do :
jmp_buf main_loop;
int... (1 Reply)
Discussion started by: Sedighzadeh
1 Replies
7. Programming
I've been having trouble with reading past the end-of-file in C. Can anyone find my stupid mistake?
This is the minimal code needed to cause the error for me:
FILE *f = fopen(name, "r");
if (!f)
return;
pari_sp ltop = avma;
char line;
while(fgets(line, 1100, f) != NULL)
printf(".");... (23 Replies)
Discussion started by: CRGreathouse
23 Replies
8. Programming
hello,
i'm trying to write a C-program that reads a file line by line.
(and searches each line for a given string)
This file is an special ASCII-database-file, with a lot of entries.
I checked the line with most length, and it was about 4000 characters.
With google i found several... (4 Replies)
Discussion started by: p1cm1n
4 Replies
9. UNIX for Dummies Questions & Answers
May i know what are the possible causes for SIGINT other than ctrl-c?
Thanks (17 Replies)
Discussion started by: pandeesh
17 Replies
10. Shell Programming and Scripting
The following command will run and wait for input from the user.
/usr/sap/SAP/webdisp/wdispmon pf=/usr/sap/SAP/webdisp/profile
What I would like to do is (in one command):
- Add the above line to a ksh script
- Receive the output
- and send a SIGINT
I have seen many posts on how to... (3 Replies)
Discussion started by: sapsid
3 Replies
LEARN ABOUT PHP
phar.setstub
PHAR.SETSTUB(3) 1 PHAR.SETSTUB(3)
Phar::setStub - Used to set the PHP loader or bootstrap stub of a Phar archive
SYNOPSIS
public bool Phar::setStub (string $stub, [int $len = -1])
DESCRIPTION
Note
This method requires the php.ini setting phar.readonly to be set to 0 in order to work for Phar objects. Otherwise, a PharException
will be thrown.
This method is used to add a PHP bootstrap loader stub to a new Phar archive, or to replace the loader stub in an existing Phar archive.
The loader stub for a Phar archive is used whenever an archive is included directly as in this example:
<?php
include 'myphar.phar';
?>
The loader is not accessed when including a file through the phar stream wrapper like so:
<?php
include 'phar://myphar.phar/somefile.php';
?>
PARAMETERS
o $stub
- A string or an open stream handle to use as the executable stub for this phar archive.
o $len
-
RETURN VALUES
Returns TRUE on success or FALSE on failure.
ERRORS
/EXCEPTIONS
UnexpectedValueException is thrown if phar.readonly is enabled in php.ini. PharException is thrown if any problems are encountered flushing
changes to disk.
EXAMPLES
Example #1
A Phar.setStub(3) example
<?php
try {
$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
$p['a.php'] = '<?php var_dump("Hello");';
$p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
include 'phar://brandnewphar.phar/a.php';
var_dump($p->getStub());
$p['b.php'] = '<?php var_dump("World");';
$p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>');
include 'phar://brandnewphar.phar/b.php';
var_dump($p->getStub());
} catch (Exception $e) {
echo 'Write operations failed on brandnewphar.phar: ', $e;
}
?>
The above example will output:
string(5) "Hello"
string(82) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>"
string(5) "World"
string(83) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>"
CHANGELOG
+--------+------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+------------------------+
| 5.4.0 | |
| | |
| | Added $len parameter. |
| | |
+--------+------------------------+
SEE ALSO
Phar.getStub(3), Phar.createDefaultStub(3).
PHP Documentation Group PHAR.SETSTUB(3)