CN105045594A - Program output control method and system - Google Patents

Program output control method and system Download PDF

Info

Publication number
CN105045594A
CN105045594A CN201510460419.XA CN201510460419A CN105045594A CN 105045594 A CN105045594 A CN 105045594A CN 201510460419 A CN201510460419 A CN 201510460419A CN 105045594 A CN105045594 A CN 105045594A
Authority
CN
China
Prior art keywords
output
standard
signal
standard error
exported
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201510460419.XA
Other languages
Chinese (zh)
Inventor
李鹏
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Opzoon Technology Co Ltd
Original Assignee
Opzoon Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Opzoon Technology Co Ltd filed Critical Opzoon Technology Co Ltd
Priority to CN201510460419.XA priority Critical patent/CN105045594A/en
Publication of CN105045594A publication Critical patent/CN105045594A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The invention provides a program output control method and system. The method comprises: receiving a signal input by a user; identifying the signal; and according to an identification result, turning on or off standard output and/or standard error output of an output program. According to the control method, according to the signal input by the user, whether the signal is a signal for turning on or off the standard output and/or the standard error output of the output program is identified, and finally according to the identification result, the standard output and/or the standard error output of the output program is turned on or off, so that restrictions of system library functions are avoided and the effect of outputting program operation information to the terminal according to user intentions is realized.

Description

The control method that a kind of program exports and system
Technical field
The present invention relates to linux system technical field, particularly relate to control method and the system of the output of a kind of program.
Background technology
Under Linux, User space program needs various information displaying program run in terminal, but in most cases, user does not wish that various information is outputted to terminal by program frequently, because do the decline that can cause program feature like this, also interference is produced to other normal output informations simultaneously.But when program goes wrong time or time developer debugs, user often wishes information to output to terminal, this makes it possible to the state seeing that program is run timely.
Prior art carrys out the various information displaying of just program operation to terminal by a global variable, forbid when global variable set exporting, can output display when global variable does not have set, but only can control program oneself realize function, when program uses standard library function (such as printf), directly cannot be exported closedown, if there is the place using this class function in program, in program process, all may be had output display.
Summary of the invention
For defect of the prior art, the invention provides control method and the system of a kind of program output, achieve and according to the wish of user, the information that program is run can be outputted to terminal.
First aspect, the invention provides the control method that a kind of program exports, comprising:
Receive the signal of user's input;
Described signal is identified;
According to recognition result, the standard output of written-out program and/or standard error are exported and opens or close.
Optionally, described according to recognition result, the standard output of written-out program and/or standard error are exported and opens or close, comprising:
When identifying that described signal is the first signal for opening described standard output and/or standard error output, the standard output of written-out program and/or standard error being exported and opens;
Or
When identifying that described signal is the secondary signal for closing described standard output and/or standard error output, the standard output of written-out program and/or standard error being exported and closes.
Optionally, before the signal receiving user's input, described method also comprises:
Copy described standard output and/or standard error output, and obtain the first filec descriptor being used for standard output and/or standard error being exported unlatching.
Optionally, the described standard output of written-out program and/or standard error outputs is opened, and comprising:
According to described first signal, by described first filec descriptor, described standard output and/or standard error are exported unlatching.
Optionally, described before the standard output of written-out program and/or standard error are exported closedown, described method also comprises:
Open the equipment for closing written-out program, and obtain the second filec descriptor being used for standard output and/or standard error being exported closedown.
Optionally, the described standard output of written-out program and/or standard error outputs is closed, and comprising:
According to described secondary signal, by described second filec descriptor, described standard output and/or standard error are exported and closes.
Second aspect, present invention also offers the control system that a kind of program exports, comprising:
Receiver module, for receiving the signal of user's input;
Signal analysis module, for identifying described signal;
Control module, for according to recognition result, exports the standard output of written-out program and/or standard error and opens or close.
Optionally, described control module, for:
When identifying that described signal is the first signal for opening described standard output and/or standard error output, the standard output of written-out program and/or standard error being exported and opens.
Optionally, described control module, also for:
When identifying that described signal is the secondary signal for closing described standard output and/or standard error output, the standard output of written-out program and/or standard error being exported and closes.
Optionally, described system also comprises:
Replication module, for before the signal of described receiver module reception user input, copies described standard output and/or standard error output, and obtains the first filec descriptor being used for standard output and/or standard error output to open.
As shown from the above technical solution, the invention provides control method and the system of the output of a kind of program, the signal that the method inputs according to user, identify that this signal is that the standard output of written-out program and/or standard error are exported the signal or the signal of closedown opened, last according to recognition result, the standard output of written-out program and/or standard error are exported and opens or close, achieve and according to the wish of user, the information that program is run can be outputted to terminal.
Accompanying drawing explanation
In order to be illustrated more clearly in the embodiment of the present invention or technical scheme of the prior art, be briefly described to the accompanying drawing used required in embodiment or description of the prior art below, apparently, accompanying drawing in the following describes is only some embodiments of the present invention, for those of ordinary skill in the art, under the prerequisite not paying creative work, other accompanying drawing can also be obtained according to these figure.
Fig. 1 is the schematic flow sheet of the control method of a kind of program output that one embodiment of the invention provides;
Fig. 2 is the structural representation of the control system of a kind of program output that one embodiment of the invention provides.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, be clearly and completely described the technical scheme in the embodiment of the present invention, obviously, described embodiment is only the present invention's part embodiment, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, belong to the scope of protection of the invention.
The schematic flow sheet of the control method that a kind of program that Fig. 1 shows one embodiment of the invention to be provided exports, as shown in Figure 1, the method comprises the following steps:
101, the signal of user's input is received;
102, described signal is identified;
103, according to recognition result, the standard output of written-out program and/or standard error are exported and opens or close.
The signal that said method inputs according to user, identify that this signal is that the standard output of written-out program and/or standard error are exported the signal or the signal of closedown opened, last according to recognition result, the standard output of written-out program and/or standard error are exported and opens or close, achieve and according to the wish of user, the information that program is run can be outputted to terminal.
It should be noted that, above-mentioned standard output and standard error export the equipment that can be understood as the various information of written-out program.
According to recognition result in above-mentioned steps 103, the standard output of written-out program and/or standard error are exported and open or close, comprising:
When identifying that described signal is the first signal for opening described standard output and/or standard error output, the standard output of written-out program and/or standard error being exported and opens;
Or
When identifying that described signal is the secondary signal for closing described standard output and/or standard error output, the standard output of written-out program and/or standard error being exported and closes.
In said method, in default situations, standard output and standard error export the state for closing, any output information is not had like this when program is run, open to export at follow-up recovery standard output and standard error, receive the signal of user's input in above-mentioned steps 101 before, described method also comprises unshowned step 100 in Fig. 1:
100, copy described standard output and/or standard error output, and obtain the first filec descriptor being used for standard output and/or standard error being exported unlatching.
Below the above-mentioned concrete steps standard output of written-out program and/or standard error being exported unlatching or closedown are described in detail.
Comprise the following steps when the standard output of written-out program and/or standard error are exported and close:
Step 1: before user's standard of closure exports and/or standard error exports, namely the equipment opened for closing written-out program open/dev/null, and obtain the second filec descriptor fd_null being used for standard output and/or standard error output to close.
Step 2: receive the SIGUSR2 signal that user sends, according to described secondary signal SIGUSR2, by described second filec descriptor fd_null, described standard output and/or standard error are exported and closes, standard output now and/or standard error export and are equivalent to point to/this equipment of dev/null, also be understandable that this equipment can not export, this equipment can be understood as the display interface etc. of terminal.
Will be understood that, by function dup2 (the second filec descriptor, standard output and/or standard error export), described standard output and/or standard error are exported closedown.
Comprise the following steps when the standard output of written-out program and/or standard error are exported and open:
Step 3: copy described standard output and/or standard error output, obtain the copy of standard output and/or standard error output, and obtain the first filec descriptor std_dup being used for standard output and/or standard error being exported unlatching.
Step 4: receive the SIGUSR1 signal that user sends, according to described first signal SIGUSR1, by described first filec descriptor std_dup described standard output and/or standard error exported and open, namely export the various information displaying that all program can be run to terminal by the first filec descriptor and the standard output copied and/or standard error.
That is, when standard output and/or standard error export closedown, by dup2, standard output and/or standard error output are reverted to its copy std_dup.
In above-mentioned steps, user can send SIGUSR1 signal by " killSIGUSR1 process number " to program, makes program recovery open standard output and/or standard error output; Send SIGUSR2 signal by " killSIGUSR2 process number " to program, stop standard output and/or standard error are exported.
The output of various information program run of said method user dynamic and closedown, user, when sending SIGUSR1 information to program, makes the standard output of program and standard error export and is restored.When not needing program output information, by sending SIGUSR2 signal to program, making stop standard output and standard error, reaching the object forbidding exporting.Not by the restriction of system library function.
The structural representation of the control system that a kind of program that Fig. 2 shows the embodiment of the present invention to be provided exports, this system comprises:
Receiver module 21, for receiving the signal of user's input;
Signal analysis module 22, for identifying described signal;
Control module 23, for according to recognition result, exports the standard output of written-out program and/or standard error and opens or close.
One of the present embodiment preferred embodiment in, described control module 23, for:
When identifying that described signal is the first signal for opening described standard output and/or standard error output, the standard output of written-out program and/or standard error being exported and opens.
In another attainable mode, described control module 23, also for:
When identifying that described signal is the secondary signal for closing described standard output and/or standard error output, the standard output of written-out program and/or standard error being exported and closes.
One of the present embodiment preferred embodiment in, described system also comprises in Fig. 2 unshowned:
Replication module, for before the signal of described receiver module reception user input, copies described standard output and/or standard error output, and obtains the first filec descriptor being used for standard output and/or standard error output to open.
For system embodiment, due to itself and embodiment of the method basic simlarity, so description is fairly simple, relevant part illustrates see the part of embodiment of the method.
Above embodiment only in order to technical scheme of the present invention to be described, is not intended to limit; Although with reference to previous embodiment to invention has been detailed description, those of ordinary skill in the art is to be understood that; It still can be modified to the technical scheme described in foregoing embodiments, or carries out equivalent replacement to wherein portion of techniques feature; And these amendments or replacement, do not make the essence of appropriate technical solution depart from the spirit and scope of various embodiments of the present invention technical scheme.

Claims (10)

1. a control method for program output, is characterized in that, comprising:
Receive the signal of user's input;
Described signal is identified;
According to recognition result, the standard output of written-out program and/or standard error are exported and opens or close.
2. the method as requested described in 1, is characterized in that, described according to recognition result, the standard output of written-out program and/or standard error is exported and opens or close, comprising:
When identifying that described signal is the first signal for opening described standard output and/or standard error output, the standard output of written-out program and/or standard error being exported and opens;
Or
When identifying that described signal is the secondary signal for closing described standard output and/or standard error output, the standard output of written-out program and/or standard error being exported and closes.
3. method according to claim 2, is characterized in that, before the signal receiving user's input, described method also comprises:
Copy described standard output and/or standard error output, and obtain the first filec descriptor being used for standard output and/or standard error being exported unlatching.
4. method according to claim 3, is characterized in that, the described standard output of written-out program and/or standard error outputs is opened, and comprising:
According to described first signal, by described first filec descriptor, described standard output and/or standard error are exported unlatching.
5. method according to claim 2, is characterized in that, described before the standard output of written-out program and/or standard error are exported closedown, described method also comprises:
Open the equipment for closing written-out program, and obtain the second filec descriptor being used for standard output and/or standard error being exported closedown.
6. method according to claim 5, is characterized in that, the described standard output of written-out program and/or standard error outputs is closed, and comprising:
According to described secondary signal, by described second filec descriptor, described standard output and/or standard error are exported and closes.
7. a control system for program output, is characterized in that, comprising:
Receiver module, for receiving the signal of user's input;
Signal analysis module, for identifying described signal;
Control module, for according to recognition result, exports the standard output of written-out program and/or standard error and opens or close.
8. the system as requested described in 7, is characterized in that, described control module, for:
When identifying that described signal is the first signal for opening described standard output and/or standard error output, the standard output of written-out program and/or standard error being exported and opens.
9. system according to claim 7, is characterized in that, described control module, also for:
When identifying that described signal is the secondary signal for closing described standard output and/or standard error output, the standard output of written-out program and/or standard error being exported and closes.
10. system according to claim 8 or claim 9, it is characterized in that, described system also comprises:
Replication module, for before the signal of described receiver module reception user input, copies described standard output and/or standard error output, and obtains the first filec descriptor being used for standard output and/or standard error output to open.
CN201510460419.XA 2015-07-30 2015-07-30 Program output control method and system Pending CN105045594A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201510460419.XA CN105045594A (en) 2015-07-30 2015-07-30 Program output control method and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510460419.XA CN105045594A (en) 2015-07-30 2015-07-30 Program output control method and system

Publications (1)

Publication Number Publication Date
CN105045594A true CN105045594A (en) 2015-11-11

Family

ID=54452159

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510460419.XA Pending CN105045594A (en) 2015-07-30 2015-07-30 Program output control method and system

Country Status (1)

Country Link
CN (1) CN105045594A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111209114A (en) * 2019-12-31 2020-05-29 深圳Tcl新技术有限公司 System memory releasing method, device and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1967499A (en) * 2006-04-24 2007-05-23 华为技术有限公司 Journal output system and output method
CN102073581A (en) * 2009-11-23 2011-05-25 新奥特(北京)视频技术有限公司 Method and system for outputting debug information
US8990776B2 (en) * 2010-11-16 2015-03-24 Zhongshan Innocloud Intellectual Property Services Co., Ltd. Computing device and device driver debugging method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1967499A (en) * 2006-04-24 2007-05-23 华为技术有限公司 Journal output system and output method
CN102073581A (en) * 2009-11-23 2011-05-25 新奥特(北京)视频技术有限公司 Method and system for outputting debug information
US8990776B2 (en) * 2010-11-16 2015-03-24 Zhongshan Innocloud Intellectual Property Services Co., Ltd. Computing device and device driver debugging method

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
65172607: "《linux shell数据重定向(输入重定向与输出重定向)详细分析》", 《百度文库》 *
JIN0848: "《Linux Shell(bash)重定向技巧》", 《百度文库》 *
WDSXMN: "《Linux重定向_All》", 《百度文库》 *
宋敬彬: "《LINUX网络编程》", 31 January 2010 *
袁建红: "《实用操作系统》", 30 September 2002 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111209114A (en) * 2019-12-31 2020-05-29 深圳Tcl新技术有限公司 System memory releasing method, device and storage medium

Similar Documents

Publication Publication Date Title
US9990209B2 (en) Digital assistance device for facilitating multi-stage setup
CN106887225B (en) Acoustic feature extraction method and device based on convolutional neural network and terminal equipment
WO2021208512A1 (en) Method and apparatus for acquiring control information of user interface, terminal and storage medium
CN108664364B (en) Terminal testing method and device
US20160357519A1 (en) Natural Language Engine for Coding and Debugging
CN104966053A (en) Face recognition method and recognition system
US20150317234A1 (en) System, method, apparatus and computer program for automatic evaluation of user interfaces in software programs
US20190012005A1 (en) Method and device for asynchronous touch and asynchronous display on dual-screen and computer readable storage medium
US10131444B1 (en) System and method of providing clipboard cut and paste operations in an avionics touchscreen system
WO2017020459A1 (en) Method and apparatus for configuring plugin package for host
CN102868699A (en) Method and tool for vulnerability detection of server providing data interaction services
CN111241552A (en) Safety auxiliary system of autonomous unmanned system
US10061690B2 (en) Computing device and method for performing test of rehosting
US20160267271A1 (en) Detection of malicious software behavior using signature-based static analysis
CN105045594A (en) Program output control method and system
CN102929688A (en) Method for realizing simulator for simulating touch screen and simulator
CN110352400A (en) Method and apparatus for handling message
US20140372929A1 (en) Apparatus and method for providing user interface regarding aeronautical system configuration
KR101745330B1 (en) Computer input automation system
CN106155513B (en) A kind of control method and device projecting touch screen
CN109032752B (en) Cloud platform based operation revocation
JP6797293B2 (en) Methods and devices for implementing accessibility features in applications
US20160179483A1 (en) Automatic componentization engine
CN110764840B (en) Method, device and system for wirelessly debugging android device
CN106873913B (en) Method for partitioning embedded system by self-adapting to different flash

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination