Skip to contentSkip to conversation

Redirecting output

DISCUSSION shafa.hidee 4 participants 4 messages Mar 23, 2005

lore
Share & tools
lore
#0 lore raw

Hi,
I have created a dummy module for learning device driver in linux. I
want to redirect the standard output of printk to my xterm. But by default it is redirected to tty.

I have remote logged into the machine.

Please help.

Regards
Shafa.hidee

#1 lore raw
Quoted 4 lines

Hi,
I have created a dummy module for learning device driver in linux. I
want to redirect the standard output of printk to my xterm. But by default it is redirected to tty.

What shall happen if you close the pts of the xterm?

Jan Engelhardt

#2 lore raw
In reply to shafa.hidee

hoi :)

Quoted 3 lines · shafa.hidee

I have created a dummy module for learning device driver in linux. I
want to redirect the standard output of printk to my xterm. But by default it is redirected to tty.

The kernel does not have 'standard output', so you can't redirect it. Please consult the manual for dmesg and syslog.

And please have a look at a good Linux kernel book. This will help you understand the kernel and will answer most of your questions.

Signature · 1 line
Martin Waitz
#3 lore raw
In reply to shafa.hidee
Quoted 6 lines · shafa.hidee

I have created a dummy module for learning device driver in linux. I
want to redirect the standard output of printk to my xterm. But by default it is redirected to tty.

I have remote logged into the machine.

You can do this from within the module_init() handler only:

module_init_handler(...)

{
	mm_segment_t old_fs;

	....
	old_fs = set_fs(KERNEL_DS);
	sys_write(1, "foo\n", 4);
	set_fs(old_fs);
	...
}

The text comes out on modprobe's standard output.

Don't tell anyone I told you this.