Sponsored Content
Full Discussion: Help with redirection
Top Forums Programming Help with redirection Post 11771 by auswipe on Wednesday 12th of December 2001 12:21:05 AM
Old 12-12-2001
Quote:
Here is my problem. I don't know make this redirection thing work. The output file (called output.c) looks like this

#include

int main()
{
int k;
int m;

print f("%d\n", k);
printf("%d\n", m);

return 0;
}
The reason that you are getting a bunch of numbers is that the int vars k and m are never assigned a value. You are displaying the values of what is in the memory address of k and in the memory address of m at the time of execution. The contents of an unassigned variable at execution time is commonly referred to as "compilter garbage".
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

redirection

Hi, The code below works, it's a part of a bash shell script that serve to search a pattern $pattern_da_cercare in the files contained in a directory $directory_iniziale. Now the proble is: How can I redirect stderr to a file? PS: so I want to redirect ALL the errors to a file. I tryed... (9 Replies)
Discussion started by: DNAx86
9 Replies

2. Shell Programming and Scripting

redirection problem

hi all, how to redirect the stdout msg in command line and file at the same time? e.g i got the script named test.sh, content as following: #!/bin/sh echo "111" when i run the script ./test.sh > log.log, it will wirte the "111" into log.log, but how to show the "111" in command line... (2 Replies)
Discussion started by: eric_wong_ch
2 Replies

3. Shell Programming and Scripting

Perl Redirection

Hi, I have a Perl script that finds some files based on some criteria and then it processes the file contents using some logic. Extract: print "Started ... "; my $command = "<unix command>"; @arr=`$command`; $size=@arr; print "Size: ".$size If I turn on the Perl debugging option then I... (3 Replies)
Discussion started by: King Nothing
3 Replies

4. UNIX for Dummies Questions & Answers

Help with Redirection

Hi Guys, I m new to UNIX and new to this forum. Was wondering if someone can help me understand redirection (standard input output pipeline etc) for starters, not too sure what this would mean who | sort > sortedfile | pr | lp im starting to understand common commands but when throwing... (2 Replies)
Discussion started by: jmack123
2 Replies

5. Shell Programming and Scripting

I/O redirection

Hello everyone,I'm reading a book and there's code fragment: exec 3>&1 ls -l 2>&1 >&3 3>&- | grep bad 3>&- exec 3>&- It says that the red part of that code does not close fd 3 but the green does close the fd 3.I can't understand that.....Why?Any predicate will be appreciated.:) (18 Replies)
Discussion started by: homeboy
18 Replies

6. Web Development

Apache redirection

Hello I have a domain where i need a redirection as described below : i.e mydomain.com/t-ABC-048796/sample.jpg must redirect to mydomain.com/jjj/top/8796/sample.jpg As you can see from the source URL (mydomain.com/t-ABC-048796/sample.jpg) i need the last four characters... (2 Replies)
Discussion started by: unimaxlin
2 Replies

7. Shell Programming and Scripting

Redirection question

I want to redirect stderr and have the following peice of code $ cat t1.ksh #!/bin/ksh func2() { diff /tmp/jdlkwjdlkejew /tmp/djlkwejdlewdjew >$OUTPUT_FILE 2>>$ERR_FILE } func1() { let counter=0 while do print -u2 "Error: In main function" func2 let... (1 Reply)
Discussion started by: BeefStu
1 Replies

8. Shell Programming and Scripting

Redirection

Hello All, I am using the below script to gather various tools running by the user, we have more than 100 tools running on the server so my challenge is to redirect memory & cpu load to the file with the name of the tool.so am using the below script i am stucking how to redirect to the file... (2 Replies)
Discussion started by: ajaincv
2 Replies

9. Solaris

solaris redirection

Hi I am using solaris 10. When running a grep command with multiple files the output is the same as the order of the input. As soon as I pipe the output to another command then it seems that standard error takes precedence, over standard output and gets sent to the pipe first. ie grep -c... (7 Replies)
Discussion started by: chronics
7 Replies

10. UNIX for Dummies Questions & Answers

about different redirection

explain the redirections 1>, 2>, 3>, ..... and 1< ,2<,3<..... where we use these things thanks Thread moved from AIX forum (2 Replies)
Discussion started by: tsurendra
2 Replies
setjmp(3UCB)					     SunOS/BSD Compatibility Library Functions					      setjmp(3UCB)

NAME
setjmp, longjmp, _setjmp, _longjmp - non-local goto SYNOPSIS
/usr/ucb/cc [ flag ... ] file ... #include <setjmp.h> int setjmp(env) jmp_buf env; void longjmp(env, val) jmp_buf env; int val; int _setjmp(env) jmp_buf env; void _longjmp(env, val) jmp_buf env; int val; DESCRIPTION
The setjmp() and longjmp() functions are useful for dealing with errors and interrupts encountered in a low-level subroutine of a program. The setjmp() function saves its stack environment in env for later use by longjmp(). A normal call to setjmp() returns zero. setjmp() also saves the register environment. If a longjmp() call will be made, the routine which called setjmp() should not return until after the longjmp() has returned control (see below). The longjmp() function restores the environment saved by the last call of setjmp(), and then returns in such a way that execution continues as if the call of setjmp() had just returned the value val to the function that invoked setjmp(); however, if val were zero, execution would continue as if the call of setjmp() had returned one. This ensures that a ``return'' from setjmp() caused by a call to longjmp() can be distinguished from a regular return from setjmp(). The calling function must not itself have returned in the interim, otherwise longjmp() will be returning control to a possibly non-existent environment. All memory-bound data have values as of the time longjmp() was called. The CPU and floating-point data registers are restored to the values they had at the time that setjmp() was called. But, because the register storage class is only a hint to the C compiler, variables declared as register variables may not necessarily be assigned to machine registers, so their values are unpredictable after a longjmp(). This is especially a problem for programmers trying to write machine-independent C routines. The setjmp() and longjmp() functions save and restore the signal mask while _setjmp() and _longjmp() manipulate only the C stack and regis- ters. None of these functions save or restore any floating-point status or control registers. EXAMPLES
Example 1 Examples of setjmp() and longjmp(). The following example uses both setjmp() and longjmp() to return the flow of control to the appropriate instruction block: #include <stdio.h> #include <setjmp.h> #include <signal.h> #include <unistd.h> jmp_buf env; static void signal_handler(); main() { int returned_from_longjump, processing = 1; unsigned int time_interval = 4; if ((returned_from_longjump = setjmp(env)) != 0) switch (returned_from_longjump) { case SIGINT: printf("longjumped from interrupt %d ",SIGINT); break; case SIGALRM: printf("longjumped from alarm %d ",SIGALRM); break; } (void) signal(SIGINT, signal_handler); (void) signal(SIGALRM, signal_handler); alarm(time_interval); while (processing) { printf(" waiting for you to INTERRUPT (cntrl-C) ... "); sleep(1); } /* end while forever loop */ } static void signal_handler(sig) int sig; { switch (sig) { case SIGINT: ... /* process for interrupt */ longjmp(env,sig); /* break never reached */ case SIGALRM: ... /* process for alarm */ longjmp(env,sig); /* break never reached */ default: exit(sig); } } When this example is compiled and executed, and the user sends an interrupt signal, the output will be: longjumped from interrupt Additionally, every 4 seconds the alarm will expire, signalling this process, and the output will be: longjumped from alarm SEE ALSO
cc(1B), sigvec(3UCB), setjmp(3C), signal(3C) NOTES
Use of these interfaces should be restricted to only applications written on BSD platforms. Use of these interfaces with any of the system libraries or in multi-thread applications is unsupported. BUGS
The setjmp() function does not save the current notion of whether the process is executing on the signal stack. The result is that a longjmp() to some place on the signal stack leaves the signal stack state incorrect. On some systems setjmp() also saves the register environment. Therefore, all data that are bound to registers are restored to the values they had at the time that setjmp() was called. All memory-bound data have values as of the time longjmp() was called. However, because the register storage class is only a hint to the C compiler, variables declared as register variables may not necessarily be assigned to machine registers, so their values are unpredictable after a longjmp(). When using compiler options that specify automatic register alloca- tion (see cc(1B)), the compiler will not attempt to assign variables to registers in routines that call setjmp(). The longjmp() function never causes setjmp() to return 0, so programmers should not depend on longjmp() being able to cause setjmp() to return 0. SunOS 5.11 7 Apr 1993 setjmp(3UCB)
All times are GMT -4. The time now is 04:27 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy